From c7ab4671bbd46ec4706e75e0a3a7203b81e2a614 Mon Sep 17 00:00:00 2001 From: myfreeer Date: Sat, 5 Oct 2024 11:58:27 +0800 Subject: [PATCH] test: fix ts-jest module resolution https://github.com/kulshekhar/ts-jest/issues/1057 --- jest.config.js | 17 +++++++++++++++++ package.json | 3 --- tsconfig.json | 3 ++- 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 jest.config.js diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 00000000..9491a44d --- /dev/null +++ b/jest.config.js @@ -0,0 +1,17 @@ +/** @type {import('@jest/types').Config.ProjectConfig} */ +const config = { + transform: { + '\\.[jt]sx?$': 'ts-jest', + }, + 'globals': { + 'ts-jest': { + 'useESM': true + } + }, + moduleNameMapper: { + '^\\.(.+)\\.js': '.$1' + }, + extensionsToTreatAsEsm: ['.ts'], +}; + +module.exports = config; diff --git a/package.json b/package.json index 7d4a1c0d..08739f70 100644 --- a/package.json +++ b/package.json @@ -17,9 +17,6 @@ "prepack": "npm run clean && npm run build", "postshrinkwrap": "node package-lock-resolved.js" }, - "jest": { - "preset": "ts-jest" - }, "dependencies": { "cheerio": "^1.0.0", "css-url-parser": "^1.1.3", diff --git a/tsconfig.json b/tsconfig.json index dfe9adcd..46256dac 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,8 @@ "esModuleInterop": true, "removeComments": false, "strict": true, - "declarationMap": true + "declarationMap": true, + "allowJs": true }, "include": [ "src"