El *_*ude 6 unit-testing angularjs ionic-framework jestjs ionic3
我不确定为什么将GA导入单元测试失败。我怎样才能解决这个问题?
也许JEST错误应该使我指向正确的方向,但不幸的是,它没有:
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Run Code Online (Sandbox Code Playgroud)
....
/Users/me/app/node_modules/@ionic-native/google-analytics/index.js:20
import { Injectable } from '@angular/core';
^^^^^^
SyntaxError: Unexpected token import
2 | import { Http } from '@angular/http';
3 | import { Events } from 'ionic-angular';
> 4 | import { GoogleAnalytics } from '@ionic-native/google-analytics';
Run Code Online (Sandbox Code Playgroud)
通过指示我扩展了我package.json的
"transformIgnorePatterns": [
"<rootDir>/node_modules"
],
Run Code Online (Sandbox Code Playgroud)
但是它仍然失败,并显示相同的错误
我想我已经找到了解决这个问题的方法
npm run eject在您的代码库中运行,package.json,如下所示,
--env=jsdom --transformIgnorePatterns 'node_modules/(?!(@ionic|<other-package-need-to-transform>)/)该解决方案对于离子/反应和离子/角度很常见
| 归档时间: |
|
| 查看次数: |
190 次 |
| 最近记录: |