Repository navigation
Expand file tree
/
Copy pathjest.config.js
More file actions
117 lines (116 loc) · 4.23 KB
/
Copy pathjest.config.js
File metadata and controls
117 lines (116 loc) · 4.23 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
const defaultConfig = {
testEnvironment: 'node',
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
// The parser is ESM-only: its `exports` offers `import`, and jest's CJS runtime asks for
// `require`. Naming the files steps past the exports gate for this package alone — widening
// the export conditions pulls every other dependency's ESM build in with it. The cost is that
// this path must track the parser's own `exports`.
'^@apexdevtools/apex-log-parser$':
'<rootDir>/node_modules/@apexdevtools/apex-log-parser/dist/node.js',
},
transform: {
'^.+\\.(ts|js)?$': [
'@swc/jest',
{
jsc: {
target: 'esnext',
parser: { decorators: true, syntax: 'typescript' },
// Match the bundles (and log-viewer/tsconfig.json): with `define`
// semantics a class field initializer shadows Lit's reactive
// accessor, so property assignments never trigger a re-render.
transform: { useDefineForClassFields: false },
},
},
],
},
testPathIgnorePatterns: [
'<rootDir>/node_modules/',
'<rootDir>/out/',
'<rootDir>/test/playwright/',
],
setupFilesAfterEnv: ['<rootDir>/src/__tests__/setup.ts'],
testMatch: ['**/?(*.)+(spec|test).ts'],
extensionsToTreatAsEsm: ['.ts', '.tsx'],
};
/** @type {import('@jest/types').Config.InitialOptions} */
export default {
projects: [
{
...defaultConfig,
displayName: 'log-viewer',
rootDir: '<rootDir>/log-viewer',
moduleNameMapper: {
...defaultConfig.moduleNameMapper,
// The webview loads the parser's browser build, which yields without `setImmediate`.
'^@apexdevtools/apex-log-parser$':
'<rootDir>/node_modules/@apexdevtools/apex-log-parser/dist/browser.js',
'^#test-helpers/(.*)\\.js$': '<rootDir>/src/__tests__/helpers/$1',
'^#core/(.*)\\.js$': '<rootDir>/src/core/$1',
// Stylesheet imports have no transform here; the `.js` rule above runs first, so the
// `*.css.ts` style modules are unaffected.
'\\.css$': '<rootDir>/src/__tests__/mocks/styleStub.ts',
// `vscode-single-select` is excluded because `components/VsSelect.ts` extends the real
// class, and an empty module would make that `extends undefined` at load. A mapper
// beats `jest.requireActual`, so no suite can ask for a real element back.
'^#vscode-elements/(?!vscode-single-select\\.js$)':
'<rootDir>/src/__tests__/mocks/emptyModule.ts',
// One bundle, not the ~720-module `require` entry; the path must track pixi's `dist/`.
'^pixi\\.js$': '<rootDir>/node_modules/pixi.js/dist/pixi.mjs',
},
transform: {
...defaultConfig.transform,
'^.+\\.mjs$': defaultConfig.transform['^.+\\.(ts|js)?$'],
},
transformIgnorePatterns: [
// allow transformation of pixi.js and its dependencies
'<rootDir>/node_modules/(?!pixi\\.js)',
],
},
{
...defaultConfig,
displayName: 'lana',
rootDir: '<rootDir>/lana',
moduleNameMapper: {
...defaultConfig.moduleNameMapper,
'^vscode$': '<rootDir>/src/__tests__/mocks/vscode.ts',
},
transformIgnorePatterns: [
// allow lit/@lit transformation
'<rootDir>/node_modules/(?!@?lit)',
],
},
{
...defaultConfig,
displayName: 'docs',
rootDir: '<rootDir>/lana-docs',
testEnvironment: 'jsdom',
testEnvironmentOptions: { url: 'http://localhost/debug-log-analyzer/demo/viewer.html' },
testMatch: ['**/__tests__/**/*.test.{ts,tsx}'],
testPathIgnorePatterns: [
'<rootDir>/node_modules/',
'<rootDir>/build/',
'<rootDir>/.docusaurus/',
],
setupFilesAfterEnv: [],
moduleNameMapper: {
...defaultConfig.moduleNameMapper,
'^@site/(.*)$': '<rootDir>/$1',
'\\.css$': '<rootDir>/src/__tests__/styleStub.ts',
},
transform: {
'^.+\\.(ts|tsx|js)$': [
'@swc/jest',
{
jsc: {
target: 'esnext',
parser: { syntax: 'typescript', tsx: true },
transform: { react: { runtime: 'automatic' } },
},
},
],
},
},
],
slowTestThreshold: 1,
};