-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
ava.config.js
43 lines (37 loc) · 1.07 KB
/
ava.config.js
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
// @ts-check
/**
* Get the intended boolean value from the given string.
*/
function getBoolean(value) {
if (value === undefined) {
return false;
}
const asNumber = Number(value);
return Number.isNaN(asNumber)
? Boolean(String(value).toLowerCase().replace("false", ""))
: Boolean(asNumber);
}
const useCompiledTests = getBoolean(process.env.USE_COMPILED_TESTS);
const testWorkFile = getBoolean(process.env.TEST_WORK_FILE);
const avaCommonConfig = {
files: testWorkFile ? ["tests/**/work.test.*"] : ["tests/**/!(work)*.test.*"],
timeout: "5m",
};
const avaTsConfig = {
...avaCommonConfig,
extensions: ["ts"],
require: ["ts-node/register", "tsconfig-paths/register"],
environmentVariables: {
TS_NODE_PROJECT: "tests/tsconfig.json",
},
};
const avaJsConfig = {
...avaCommonConfig,
files: avaCommonConfig.files.map((file) => `build/${file}`),
extensions: ["js"],
require: ["tsconfig-paths/register"],
environmentVariables: {
TS_NODE_PROJECT: "build/tests/tsconfig.json",
},
};
export default useCompiledTests ? avaJsConfig : avaTsConfig;