【发布时间】:2018-09-04 11:00:54
【问题描述】:
我正在构建一个 ionic 应用程序,并希望为几个服务添加单元测试。我正在尝试使用 typescript 开玩笑,但它似乎效果不佳。
我收到此错误:
/myuser/project/node_modules/@ionic/storage/dist/index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { NgModule } from '@angular/core';
^^^^^^
SyntaxError: Unexpected token import
现在我读到你必须添加 babel-plugin-transform-es2015-modules-commonjs 并在 babel 的测试环境中使用它。但是我使用的是 babel 7,这个插件不适用于 babel 7。有不同的解决方案吗?
我还将在下面提供我的 package.json 和 .babelrc。 gist
【问题讨论】:
标签: ionic-framework jestjs babel-jest