-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-runner.ts
More file actions
53 lines (47 loc) · 1.3 KB
/
test-runner.ts
File metadata and controls
53 lines (47 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
48
49
50
51
52
53
import { exec } from 'child_process';
import path from 'path';
const services = [
'api-gateway',
'flight-search-service',
'booking-service',
'seat-service',
'payment-service',
'discount-service',
'ticket-service',
'notification-service',
'auth-service'
];
const runTests = (service: string): Promise<void> => {
const cwd = path.join(__dirname, service);
return new Promise((resolve, reject) => {
console.log(`\n🔍 Running tests in ${service}...\n`);
exec('npx jest --passWithNoTests --silent=false', { cwd }, (error, stdout, stderr) => {
console.log(stdout);
if (error) {
console.error(`❌ Tests failed in ${service}`);
console.error(stderr);
reject(error);
} else {
console.log(`✅ Tests passed in ${service}`);
resolve();
}
});
});
};
(async () => {
let failed = false;
for (const service of services) {
try {
await runTests(service);
} catch {
failed = true;
}
}
if (failed) {
console.error('\n❌ Some tests failed.\n');
process.exit(1);
} else {
console.log('\n🎉 All tests passed.\n');
process.exit(0);
}
})();