我安装了 jest
并在创建文件的命令 jest init
中使用:
module.exports = {
clearMocks: true,
coverageDirectory: "coverage",
testEnvironment: "node",
testMatch: [
"**/__tests__/**/*.[jt]s?(x)",
"**/?(*.)+(spec|test).[tj]s?(x)"
],
testPathIgnorePatterns: [
"\\\\node_modules\\\\"
],
};
当我使用 npm run test
时出现错误:
C:\workspace\talisman\src\scripts\utils\utils.spec.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { getKeyByValue } from './utils';
^^^^^^
SyntaxError: Cannot use import statement outside a module
我该如何解决?