-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbespin.ts
More file actions
39 lines (26 loc) · 1.11 KB
/
bespin.ts
File metadata and controls
39 lines (26 loc) · 1.11 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
import { GluegunToolbox } from "gluegun";
import { TestResultState, Runtime, Config } from "@testingrequired/bespin-core";
import { CLIReporter } from "../CLIReporter";
export const name = "bespin";
export const run = async (toolbox: GluegunToolbox) => {
const { print, filesystem } = toolbox;
const configFilePath = toolbox.parameters.options?.c || "bespin.config.js";
if (!filesystem.exists(configFilePath)) {
print.error(`bespin could not find config file: ${configFilePath}`);
return;
}
const config = await Config.load(configFilePath);
config.reporters.push(new CLIReporter(toolbox));
if (toolbox.parameters.options?.testFileFilter) {
config.settings.testFileFilter = toolbox.parameters.options?.testFileFilter;
}
if (toolbox.parameters.options?.testNameFilter) {
config.settings.testNameFilter = toolbox.parameters.options?.testNameFilter;
}
const runtime = new Runtime(config);
const results = await runtime.run();
const passingRun = results
.map(([_, result]) => result)
.every(({ state }) => state === TestResultState.PASS);
process.exit(passingRun ? 0 : 1);
};