From a9ed0b8712bdf3510a6816c04ca5ae18f55d3075 Mon Sep 17 00:00:00 2001 From: Akira Hayashi Date: Fri, 31 May 2024 06:21:54 +0900 Subject: [PATCH] Transpile dependent packages under `node_modules/` to avoid error below: > SyntaxError: Cannot use import statement outside a module --- jest.config.cjs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/jest.config.cjs b/jest.config.cjs index b179663..6f217bc 100644 --- a/jest.config.cjs +++ b/jest.config.cjs @@ -1,3 +1,16 @@ +var esmModules = [ + "chalk", + "ora", + "cli-cursor", + "restore-cursor", + "log-symbols", + "is-unicode-supported", + "strip-ansi", + "ansi-regex", + "is-interactive", + "stdin-discarder", +]; + module.exports = { preset: "ts-jest/presets/js-with-babel", testEnvironment: "node", @@ -7,5 +20,8 @@ module.exports = { moduleNameMapper: { "^(\\.{1,2}/.*)\\.js$": "$1", }, + transformIgnorePatterns: [ + `node_modules/(?!(?:.pnpm/)?(${esmModules.join('|')}))`, + ], testMatch: ["**/?(*.)+(test).[tj]s?(x)"], };