-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathjest.config.js
More file actions
75 lines (73 loc) · 2.44 KB
/
Copy pathjest.config.js
File metadata and controls
75 lines (73 loc) · 2.44 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
70
71
72
73
74
75
// force timezone to UTC to allow tests to work regardless of local timezone
// generally used by snapshots, but can affect specific tests
process.env.TZ = 'UTC';
const baseConfig = require('./.config/jest.config'); // Jest configuration provided by Grafana scaffolding
const { nodeModulesToTransform, grafanaESModules } = require('./.config/jest/utils');
const esModules = [
...grafanaESModules,
'@bsull/augurs',
'monaco-promql',
'tsqtsq',
'marked',
'react-calendar',
'get-user-locale',
'memoize',
'mimic-function',
'@wojtekmaj/date-utils',
'react-router',
'cookie-es',
];
module.exports = {
...baseConfig,
testEnvironment: './jest-environment.js',
transformIgnorePatterns: [nodeModulesToTransform(esModules)],
moduleNameMapper: {
...baseConfig.moduleNameMapper,
'\\.svg$': '<rootDir>/src/test/mocks/svgMock.js',
'^.+/logger/logger$': '<rootDir>/src/test/mocks/loggerMock.ts',
'^.+/interactions$': '<rootDir>/src/test/mocks/interactionsMock.ts',
'^.+/userStorage$': '<rootDir>/src/test/mocks/userStorage.ts',
// See the mock for why react-router's SSR route-module loader is stubbed.
// react-router imports it relatively ('./routeModules.js'), so the pattern
// can't be scoped to the package name and will match any module request
// ending in `routeModules` — don't add a src/ module by that name.
'routeModules(\\.js)?$': '<rootDir>/src/test/mocks/routeModulesMock.js',
},
transform: {
// `.mjs` is matched explicitly: some ESM deps (e.g. cookie-es, via react-router)
// ship only .mjs, which `(t|j)sx?` would otherwise leave untransformed.
'^.+\\.(t|j)sx?$|^.+\\.mjs$': [
'@swc/jest',
{
sourceMaps: 'inline',
jsc: {
parser: {
syntax: 'typescript',
tsx: true,
decorators: false,
dynamicImport: true,
},
target: 'es2022',
// Add these options for proper property descriptors
keepClassNames: true,
preserveAllComments: true,
transform: {
legacyDecorator: true,
decoratorMetadata: true,
},
},
module: {
type: 'commonjs',
strict: true,
strictMode: true,
noInterop: false,
},
},
],
},
resetMocks: true,
clearMocks: true,
resetModules: true,
collectCoverageFrom: ['./src/**'],
coverageReporters: ['json-summary', 'text', 'text-summary'],
};