-
Notifications
You must be signed in to change notification settings - Fork 134
/
jest.config.js
37 lines (35 loc) · 1.44 KB
/
jest.config.js
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
const {createDefaultEsmPreset} = require('ts-jest');
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
moduleNameMapper: {
// Allows jest to find the asset files, otherwise it looks for them with the
// `?arrayBuffer` as part of the name and doesn't end up transforming them.
'^(.+)\\?arrayBuffer$': '$1'
},
moduleFileExtensions: ['ts', 'js'],
transform: {
...createDefaultEsmPreset({
tsconfig: 'tsconfig.test.json',
// The webpack 5 way to include web workers is to use
// `new Worker(new URL('./worker.js', import.meta.url));`.
// See https://webpack.js.org/guides/web-workers/
// However, the `import.meta.url` is ESM-only and Jest's support for ESM is
// still experimental. So, we need to mock it instead (or use experimental
// jest & node features).
//
// Also see https://www.npmjs.com/package/ts-jest-mock-import-meta
diagnostics: {
ignoreCodes: [1343]
},
astTransformers: {
before: [
{
path: 'ts-jest-mock-import-meta',
options: {metaObjectReplacement: {url: 'https://example.com'}}
}
]
}
}).transform,
'\\.(png|svg|wav)$': '<rootDir>/test/transformers/arraybuffer-loader.js'
}
};