-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Expand file tree
/
Copy pathjest.config.snapshots.ts
More file actions
79 lines (71 loc) · 2.4 KB
/
jest.config.snapshots.ts
File metadata and controls
79 lines (71 loc) · 2.4 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
import type {TransformOptions} from '@babel/core';
import type {Config} from '@jest/types';
const babelConfig: TransformOptions = {
presets: [
[
'@babel/preset-react',
{
runtime: 'automatic',
importSource: '@emotion/react',
},
],
[
'@babel/preset-env',
{
useBuiltIns: 'usage',
corejs: '3.41',
targets: {
node: 'current',
},
},
],
['@babel/preset-typescript', {allowDeclareFields: true, onlyRemoveTypeImports: true}],
],
plugins: [
[
'@emotion/babel-plugin',
{
sourceMap: false,
},
],
],
};
/**
* ESM packages that need to be transformed by babel-jest.
*/
const ESM_NODE_MODULES = ['screenfull', 'cbor2', 'nuqs', 'color'];
const config: Config.InitialOptions = {
// 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: {
'^.+\\.jsx?$': ['babel-jest', babelConfig as any],
'^.+\\.tsx?$': ['babel-jest', babelConfig as any],
'^.+\\.mjs?$': ['babel-jest', babelConfig as any],
},
transformIgnorePatterns: [
ESM_NODE_MODULES.length
? `/node_modules/.pnpm/(?!${ESM_NODE_MODULES.join('|')})`
: '/node_modules/',
],
moduleFileExtensions: ['js', 'ts', 'jsx', 'tsx'],
};
export default config;