-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathrun-test.ts
More file actions
35 lines (29 loc) · 992 Bytes
/
run-test.ts
File metadata and controls
35 lines (29 loc) · 992 Bytes
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
import { execSync } from 'child_process';
import * as path from 'path';
function runTests(scope: string, name: string): void {
if (!name) {
console.error('Please provide a name to test, e.g., demo');
process.exit(1);
}
const validScopes = ['apps', 'modules'];
if (!validScopes.includes(scope)) {
console.error(`Invalid scope provided. Please use one of the following: ${validScopes.join(', ')}`);
process.exit(1);
}
const jestConfigPath = path.resolve(__dirname, `src/${scope}/${name}/jest.config.ts`);
try {
execSync(`jest --projects ${jestConfigPath}`, { stdio: 'inherit' });
} catch (error) {
console.error('Error running tests:', error);
process.exit(1);
}
}
const args: string[] = process.argv.slice(2);
const scope: string | undefined = args[0];
const name: string | undefined = args[1];
if (scope && name) {
runTests(scope, name);
} else {
console.error('Usage: npm run test:dynamic <apps|modules> <name>');
process.exit(1);
}