mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
test: Workaround for Jest ESM issues
To prevent issues with Jest and ESM we transform all ESM dependencies to CJS while testing.
This commit is contained in:
parent
b3ef4ed017
commit
bfa70a40aa
@ -25,6 +25,24 @@ function jestGithubRunnerSpecs() {
|
||||
};
|
||||
}
|
||||
|
||||
// ESM libraries that need to be transformed so Jest can handle them
|
||||
const esModules = [
|
||||
'oidc-provider',
|
||||
'nanoid',
|
||||
'got',
|
||||
'quick-lru',
|
||||
'@sindresorhus/is',
|
||||
'p-cancelable',
|
||||
'@szmarczak/http-timer',
|
||||
'cacheable-request',
|
||||
'normalize-url',
|
||||
'responselike',
|
||||
'lowercase-keys',
|
||||
'mimic-response',
|
||||
'form-data-encoder',
|
||||
'cacheable-lookup',
|
||||
];
|
||||
|
||||
module.exports = {
|
||||
transform: {
|
||||
'^.+\\.ts$': [ 'ts-jest', {
|
||||
@ -32,7 +50,11 @@ module.exports = {
|
||||
diagnostics: false,
|
||||
isolatedModules: true,
|
||||
}],
|
||||
// This transformer converts ESM packages to CJS
|
||||
'^.+node_modules.+\\.js$': 'jest-esm-transformer-2',
|
||||
},
|
||||
// By default, node_modules are not transformed, but we want to transform the ESM packages
|
||||
transformIgnorePatterns: [`/node_modules/(?!(${esModules.join('|')})/)`],
|
||||
testRegex: '/test/(unit|integration)/.*\\.test\\.ts$',
|
||||
moduleFileExtensions: [
|
||||
'ts',
|
||||
|
1093
package-lock.json
generated
1093
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -185,6 +185,7 @@
|
||||
"eslint-plugin-unused-imports": "^2.0.0",
|
||||
"husky": "^4.3.8",
|
||||
"jest": "^29.5.0",
|
||||
"jest-esm-transformer-2": "^1.0.0",
|
||||
"jest-rdf": "^1.8.0",
|
||||
"markdownlint-cli2": "^0.7.1",
|
||||
"node-mocks-http": "^1.12.2",
|
||||
|
Loading…
x
Reference in New Issue
Block a user