// Import all examples const exampleIds = [ 'basic-types', 'mutations', 'interfaces', 'enums-args', 'unions', 'simple-objects', 'error-handling', 'validation', 'authorization', 'directives', ]; async function testExample(exampleId) { try { console.log(`\n๐Ÿ“ฆ Testing example: ${exampleId}`); // Import the example const { examples } = await import('./components/playground/examples/index.ts'); const example = examples[exampleId]; if (!example) { console.error(`โŒ Example ${exampleId} not found`); return false; } console.log(` โœ“ Example loaded: ${example.title}`); // Try to compile the schema const schemaCode = example.files[0].content; // Use eval to execute the code (simplified for testing) // In real playground, this would use esbuild-wasm try { // This is a simplified test - in the playground, compilation happens differently console.log(` โœ“ Schema code is ${schemaCode.length} characters`); console.log(` โœ“ Default query is ${example.defaultQuery.length} characters`); // Check that the code has the essential exports if (!schemaCode.includes('export const schema')) { console.error(` โŒ Schema code missing 'export const schema'`); return false; } console.log(' โœ“ Schema code structure looks valid'); return true; } catch (err) { console.error(` โŒ Error with example: ${err.message}`); return false; } } catch (err) { console.error(`โŒ Failed to test ${exampleId}: ${err.message}`); return false; } } async function runTests() { console.log('๐Ÿงช Testing all playground examples...\n'); const results = []; for (const exampleId of exampleIds) { const result = await testExample(exampleId); results.push({ exampleId, passed: result }); } console.log('\n๐Ÿ“Š Test Summary:'); console.log('================'); const passed = results.filter((r) => r.passed).length; const failed = results.filter((r) => !r.passed).length; results.forEach(({ exampleId, passed }) => { console.log(`${passed ? 'โœ…' : 'โŒ'} ${exampleId}`); }); console.log(`\nTotal: ${passed}/${results.length} passed`); if (failed > 0) { process.exit(1); } } runTests().catch((err) => { console.error('Test runner failed:', err); process.exit(1); });