UNPKG

js-partial-classes

Version:

A utility package for supplementing main classes with methods from partial classes, supporting both static and instance methods.

117 lines (94 loc) โ€ข 3.01 kB
import { exec } from 'child_process'; import { promisify } from 'util'; const execAsync = promisify(exec); /** * Main test runner that executes all test suites */ class TestRunner { constructor() { this.testSuites = [ /* 'basic.test.js', 'supplement.test.js', */ 'supplementAll.test.js', 'iterateDescriptors.test.js' ]; this.results = []; } async runTestSuite(testFile) { console.log(`\n๐Ÿš€ Running ${testFile}...`); console.log('='.repeat(50)); try { const { stdout, stderr } = await execAsync(`node test/${testFile}`, { cwd: process.cwd() }); if (stdout) { console.log(stdout); } if (stderr) { console.error(stderr); } return { file: testFile, success: true, output: stdout, error: stderr }; } catch (error) { console.error(`โŒ Failed to run ${testFile}:`, error.message); return { file: testFile, success: false, error: error.message }; } } async runAllTests() { console.log('๐Ÿงช Starting comprehensive test suite...\n'); console.log('๐Ÿ“‹ Test suites to run:'); this.testSuites.forEach(suite => console.log(` - ${suite}`)); const startTime = Date.now(); for (const testFile of this.testSuites) { const result = await this.runTestSuite(testFile); this.results.push(result); } const endTime = Date.now(); const duration = endTime - startTime; this.printSummary(duration); } printSummary(duration) { console.log('\n' + '='.repeat(60)); console.log('๐Ÿ“Š COMPREHENSIVE TEST SUMMARY'); console.log('='.repeat(60)); const successfulTests = this.results.filter(r => r.success); const failedTests = this.results.filter(r => !r.success); console.log(`\nโฑ๏ธ Total execution time: ${duration}ms`); console.log(`๐Ÿ“ Test suites executed: ${this.results.length}`); console.log(`โœ… Successful: ${successfulTests.length}`); console.log(`โŒ Failed: ${failedTests.length}`); if (successfulTests.length > 0) { console.log('\nโœ… Successful test suites:'); successfulTests.forEach(result => { console.log(` - ${result.file}`); }); } if (failedTests.length > 0) { console.log('\nโŒ Failed test suites:'); failedTests.forEach(result => { console.log(` - ${result.file}: ${result.error}`); }); } console.log('\n' + '='.repeat(60)); if (failedTests.length === 0) { console.log('๐ŸŽ‰ ALL TESTS PASSED! The library is working correctly.'); } else { console.log('โš ๏ธ Some tests failed. Please review the errors above.'); } console.log('='.repeat(60)); } } // Run all tests const runner = new TestRunner(); runner.runAllTests().catch(error => { console.error('โŒ Test runner error:', error); process.exit(1); });