-
Notifications
You must be signed in to change notification settings - Fork 5
/
jest.config.ts
52 lines (48 loc) · 1.5 KB
/
jest.config.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import type { Config } from '@jest/types';
import { debuggerIsAttached } from 'debugger-is-attached';
import { Duration } from 'luxon';
// eslint-disable-next-line import/no-default-export
export default async (): Promise<Config.InitialOptions> => {
const debugging = await debuggerIsAttached();
const base = {
preset: 'ts-jest/presets/default-esm',
testEnvironment: 'node',
setupFiles: ['./test/jest.d.ts'],
setupFilesAfterEnv: ['./src/polyfills.ts'],
moduleNameMapper: {
// Imports for *.edgeql files are really *.edgeql.ts files
[`(.+)\\.edgeql$`]: '$1.edgeql.ts',
},
} satisfies Config.InitialProjectOptions;
const e2e = {
...base,
displayName: 'E2E',
roots: ['test'],
testRegex: '\\.e2e-spec\\.tsx?$',
setupFiles: [
...base.setupFiles,
// Set longer timeout.
// Cannot be done at project level config.
// Don't want to override cli arg or timeout set below for debugging either.
...(debugging ? [] : ['./test/jest-setup.ts']),
],
slowTestThreshold: 60_000,
} satisfies Config.InitialProjectOptions;
return {
...base,
projects: [
{
...base,
displayName: 'Unit',
roots: ['src'],
},
e2e,
],
testTimeout: Duration.fromObject({ minutes: 1 }).toMillis(),
// WebStorm doesn't need this as it adds the cli flag automatically.
// I'm guessing VSCode needs it.
...(debugging
? { testTimeout: Duration.fromObject({ hours: 2 }).toMillis() }
: {}),
};
};