-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-runner.js
More file actions
96 lines (80 loc) · 2.6 KB
/
test-runner.js
File metadata and controls
96 lines (80 loc) · 2.6 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const { spawn } = require('child_process');
const path = require('path');
async function runTests() {
console.log('🧪 Running Study Tracker Tests\n');
// Test results
const results = {
frontend: { passed: false, output: '' },
backend: { passed: false, output: '' }
};
// Run frontend tests
console.log('📱 Running Frontend Tests...');
try {
const frontendTest = spawn('npm', ['test', '--', '--watchAll=false', '--coverage=false'], {
cwd: process.cwd(),
stdio: 'pipe',
shell: true
});
let frontendOutput = '';
frontendTest.stdout.on('data', (data) => {
frontendOutput += data.toString();
});
frontendTest.stderr.on('data', (data) => {
frontendOutput += data.toString();
});
await new Promise((resolve) => {
frontendTest.on('close', (code) => {
results.frontend.passed = code === 0;
results.frontend.output = frontendOutput;
resolve();
});
});
if (results.frontend.passed) {
console.log('✅ Frontend tests passed');
} else {
console.log('❌ Frontend tests failed');
console.log(results.frontend.output);
}
} catch (error) {
console.log('❌ Frontend tests failed to run:', error.message);
}
// Run backend tests
console.log('\n🖥️ Running Backend Tests...');
try {
const backendTest = spawn('npm', ['test'], {
cwd: path.join(process.cwd(), 'server'),
stdio: 'pipe',
shell: true
});
let backendOutput = '';
backendTest.stdout.on('data', (data) => {
backendOutput += data.toString();
});
backendTest.stderr.on('data', (data) => {
backendOutput += data.toString();
});
await new Promise((resolve) => {
backendTest.on('close', (code) => {
results.backend.passed = code === 0;
results.backend.output = backendOutput;
resolve();
});
});
if (results.backend.passed) {
console.log('✅ Backend tests passed');
} else {
console.log('❌ Backend tests failed');
console.log(results.backend.output);
}
} catch (error) {
console.log('❌ Backend tests failed to run:', error.message);
}
// Summary
console.log('\n📊 Test Summary:');
console.log(`Frontend: ${results.frontend.passed ? '✅ PASSED' : '❌ FAILED'}`);
console.log(`Backend: ${results.backend.passed ? '✅ PASSED' : '❌ FAILED'}`);
const allPassed = results.frontend.passed && results.backend.passed;
console.log(`\nOverall: ${allPassed ? '✅ ALL TESTS PASSED' : '❌ SOME TESTS FAILED'}`);
process.exit(allPassed ? 0 : 1);
}
runTests().catch(console.error);