-
Notifications
You must be signed in to change notification settings - Fork 133
/
runJest.ts
32 lines (25 loc) 路 862 Bytes
/
runJest.ts
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
import { execSync } from "child_process";
type RunJestOptions = {
path?: string;
};
export const runJest = (args: string[] = [], options: RunJestOptions = {}) => {
/**
* Returns exit code. 0 for success, 1 for failed.
*/
const rootDir = options.path || ".qawolf";
// jest-fail-fast preset overrides the transform, and configures the jasmine-fail-fast plugin
// --config={} prevents using the local jest config
let command = `npx jest --preset="@qawolf/jest-fail-fast" --rootDir=${rootDir} --testTimeout=60000 --config={}`;
// pass through other arguments to jest
if (args.length) {
command += ` ${args.join(" ")}`;
}
// log the command we run to make it clear this is an alias for npx jest
console.log(command + "\n");
try {
execSync(command, { stdio: "inherit" });
return 0;
} catch (e) {
return 1;
}
};