UNPKG

claude-code-automation

Version:

🚀 Generic project automation system with anti-compaction protection and recovery capabilities. Automatically detects project type (React, Node.js, Python, Rust, Go, Java) and provides intelligent analysis. Claude Code optimized - run 'welcome' after inst

56 lines (44 loc) 1.75 kB
/** * Error Test Fixing Script * Fixes the expect().toThrow() patterns in test files */ const fs = require('fs').promises; const path = require('path'); class ErrorTestFixer { async fixErrorTests() { console.log('🔧 Fixing error test expectations...'); const testFiles = [ 'src/core/MathEngine.test.js' ]; for (const testFile of testFiles) { await this.fixTestFile(testFile); } console.log('✅ Error test expectations fixed successfully'); } async fixTestFile(relativePath) { const filePath = path.join(process.cwd(), relativePath); try { let content = await fs.readFile(filePath, 'utf8'); console.log(`🔧 Fixing error expectations in ${relativePath}...`); // Fix the malformed error expectations // Pattern: expect(() => mathEngine.tan(90)).toBe(/Math Error/); // Should be: expect(() => mathEngine.tan(90)).toThrow(); content = content.replace( /expect\(\(\) => ([^)]+)\)\.toBe\(\/[^/]+\/\);/g, 'expect(() => $1).toThrow();' ); await fs.writeFile(filePath, content); console.log(`✅ Fixed error expectations in ${relativePath}`); } catch (error) { console.error(`❌ Error fixing ${relativePath}:`, error.message); } } } // Auto-execute const fixer = new ErrorTestFixer(); fixer.fixErrorTests() .then(() => console.log('✅ Error test fixing completed')) .catch(error => { console.error('❌ Error test fixing failed:', error); process.exit(1); });