-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathjest.config.ts
More file actions
69 lines (61 loc) · 2.04 KB
/
jest.config.ts
File metadata and controls
69 lines (61 loc) · 2.04 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { debuggerIsAttached } from 'debugger-is-attached';
import { type Config } from 'jest';
import { Duration } from 'luxon';
// eslint-disable-next-line import/no-default-export
export default async (): Promise<Config> => {
const debugging = await debuggerIsAttached();
const base = {
preset: 'ts-jest/presets/default-esm',
testEnvironment: 'node',
setupFiles: ['./test/setup/jest.d.ts'],
setupFilesAfterEnv: ['./src/polyfills.ts'],
moduleNameMapper: {
// Imports for *.edgeql files are really *.edgeql.ts files
[`(.+)\\.edgeql$`]: '$1.edgeql.ts',
// TypeScript path aliases (needed for unstable_mockModule which bypasses ts-jest resolution)
'^~/core$': '<rootDir>/src/core',
'^~/core/(.+)$': '<rootDir>/src/core/$1',
},
} satisfies Config;
const e2e = {
...base,
displayName: 'E2E',
roots: ['test'],
testRegex: '\\.e2e-spec\\.tsx?$',
// Once for all files, can't share memory, only serialized env or on disk
// globalSetup: './test/setup/globalSetup.ts',
// globalTeardown: './test/setup/globalTeardown.ts',
// Once per file.
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/setup/increase-timeout-for-debugging.ts']),
],
// Once per file, after jest is ready.
// Meant for DRYing test code.
setupFilesAfterEnv: [
...base.setupFilesAfterEnv,
'./test/setup/faker-patches.ts',
],
slowTestThreshold: 60_000,
} satisfies Config;
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() }
: {}),
};
};