-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-tests.js
More file actions
executable file
·47 lines (40 loc) · 1.3 KB
/
run-tests.js
File metadata and controls
executable file
·47 lines (40 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env node
const { spawn } = require('child_process');
// Set test environment variables
process.env.NODE_ENV = 'test';
process.env.JWT_SECRET = 'test_secret_for_testing';
process.env.JWT_EXPIRES_IN = '1h';
console.log('🚀 Starting comprehensive test suite...\n');
async function runTests() {
return new Promise((resolve, reject) => {
const jest = spawn('npx', ['jest', '--runInBand', '--verbose'], {
stdio: 'inherit',
env: { ...process.env }
});
jest.on('close', (code) => {
if (code === 0) {
console.log('\n✅ All tests completed successfully!');
resolve();
} else {
console.log('\n❌ Some tests failed.');
reject(new Error(`Tests failed with exit code ${code}`));
}
});
jest.on('error', (error) => {
console.error('❌ Error running tests:', error);
reject(error);
});
});
}
runTests()
.then(() => {
console.log('\n📊 Test Summary:');
console.log('- Unit Tests: ✅ Models, Middleware, Validation, Database');
console.log('- Integration Tests: ✅ API Endpoints');
console.log('\n🎉 Your CRUD Notes API is thoroughly tested and robust!');
process.exit(0);
})
.catch((error) => {
console.error('\n💥 Test execution failed:', error.message);
process.exit(1);
});