简体   繁体   English

JEST with Angular SyntaxError: Unexpected token 'export'

[英]JEST with Angular SyntaxError: Unexpected token 'export'

ProjectDir\node_modules\lodash-es\lodash.js:10 export { default as add } from './add.js'; ProjectDir\node_modules\lodash-es\lodash.js:10 export { default as add } from './add.js'; ^^^^^^ ^^^^^^

SyntaxError: Unexpected token 'export' at Runtime.createScriptFromCode (../../node_modules/jest-runtime/build/index.js:1728:14) at Object. SyntaxError:在 Object 的 Runtime.createScriptFromCode (../../node_modules/jest-runtime/build/index.js:1728:14) 出现意外的令牌“导出”。 (../../node_modules/ng2-charts/fesm2015/ng2-charts.mjs:5:23) (../../node_modules/ng2-charts/fesm2015/ng2-charts.mjs:5:23)

I managed to solve this error following the link below with some variations, but the way that solved my problem was to add the following configuration to the "jset.config.js" file:我设法通过以下链接通过一些变体解决了此错误,但解决我的问题的方法是将以下配置添加到“jset.config.js”文件中:

moduleNameMapper: {
  "lodash-es": "lodash",
}

Jest setup "SyntaxError: Unexpected token export" 开玩笑设置“SyntaxError:意外的令牌导出”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM