-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Expand file tree
/
Copy pathjest.config.snapshots.ts
More file actions
81 lines (73 loc) · 2.37 KB
/
jest.config.snapshots.ts
File metadata and controls
81 lines (73 loc) · 2.37 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
76
77
78
79
80
81
import type {Config} from '@jest/types';
import type {Options as SwcOptions} from '@swc/core';
const swcConfig: SwcOptions = {
isModule: true,
module: {
type: 'commonjs',
},
sourceMaps: 'inline',
jsc: {
target: 'esnext',
parser: {
syntax: 'typescript',
tsx: true,
dynamicImport: true,
},
transform: {
react: {
runtime: 'automatic',
importSource: '@emotion/react',
},
},
experimental: {
plugins: [
['@swc-contrib/mut-cjs-exports', {}],
[
'@swc/plugin-emotion',
{
sourceMap: false,
autoLabel: 'never',
},
],
],
},
},
};
/**
* ESM packages that need to be transformed.
*/
const ESM_NODE_MODULES = ['screenfull', 'cbor2', 'nuqs', 'color'];
const config: Config.InitialOptions = {
cacheDirectory: '.cache/jest-snapshots',
// testEnvironment and testMatch are the core differences between this and the main config
testEnvironment: 'node',
testMatch: ['<rootDir>/static/**/*.snapshots.tsx'],
testPathIgnorePatterns: ['/node_modules/'],
setupFiles: ['<rootDir>/tests/js/sentry-test/snapshots/snapshot-setup.ts'],
setupFilesAfterEnv: ['<rootDir>/tests/js/sentry-test/snapshots/snapshot-framework.ts'],
moduleNameMapper: {
'\\.(css|less|png|gif|jpg|woff|mp4)$':
'<rootDir>/tests/js/sentry-test/mocks/importStyleMock.js',
'^sentry/(.*)': '<rootDir>/static/app/$1',
'^@sentry/scraps/(.*)': '<rootDir>/static/app/components/core/$1',
'^getsentry/(.*)': '<rootDir>/static/gsApp/$1',
'^admin/(.*)': '<rootDir>/static/gsAdmin/$1',
'^sentry-fixture/(.*)': '<rootDir>/tests/js/fixtures/$1',
'^sentry-test/(.*)': '<rootDir>/tests/js/sentry-test/$1',
'^getsentry-test/(.*)': '<rootDir>/tests/js/getsentry-test/$1',
'^sentry-locale/(.*)': '<rootDir>/src/sentry/locale/$1',
'\\.(svg)$': '<rootDir>/tests/js/sentry-test/mocks/svgMock.js',
'^echarts/(.*)': '<rootDir>/tests/js/sentry-test/mocks/echartsMock.js',
'^zrender/(.*)': '<rootDir>/tests/js/sentry-test/mocks/echartsMock.js',
},
transform: {
'^.+\\.[mc]?[jt]sx?$': ['@swc/jest', swcConfig],
},
transformIgnorePatterns: [
ESM_NODE_MODULES.length
? `/node_modules/.pnpm/(?!${ESM_NODE_MODULES.join('|')})`
: '/node_modules/',
],
moduleFileExtensions: ['js', 'ts', 'jsx', 'tsx'],
};
export default config;