2024-10-10 04:45:50 -04:00
|
|
|
const {createDefaultEsmPreset} = require('ts-jest');
|
|
|
|
|
|
|
|
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
2023-05-02 12:09:23 -04:00
|
|
|
module.exports = {
|
2024-10-10 04:45:50 -04:00
|
|
|
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'],
|
2023-05-02 12:09:23 -04:00
|
|
|
transform: {
|
2024-10-10 04:45:50 -04:00
|
|
|
...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,
|
2023-05-02 12:09:23 -04:00
|
|
|
'\\.(png|svg|wav)$': '<rootDir>/test/transformers/arraybuffer-loader.js'
|
|
|
|
}
|
|
|
|
};
|