我看到了一些其他的答案和GitHub问题描述了这个问题,但是在我的情况下,我还没有找到解决方案。当我尝试运行jest时,我遇到了可怕的SyntaxError: Unexpected token export
。
project/node_modules/@agm/core/index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){export * from './directives';
这些测试运行的代码本身没有问题。错误似乎来自于jest本身。似乎是jest正在转换文件,但我可能错了。
我的jest配置如下:
"jest": {
"preset": "jest-preset-angular",
"setupTestFrameworkScriptFile": "<rootDir>/setup-jest.ts",
"transformIgnorePatterns": [
"node_modules"
]
}
我尝试更新
transformIgnorePatterns
为"<rootDir>/node_modules/(?!@agm)"
和"node_modules/(?!@agm)"
,"node_modules/(?!@agm/core)"
,但这些都似乎没有任何区别。我该如何让jest正确处理从
@agm/core
导入的文件?