【发布时间】:2019-06-29 21:24:34
【问题描述】:
我不确定为什么将 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".
....
/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';
根据指示,我扩展了我的package.json
"transformIgnorePatterns": [
"<rootDir>/node_modules"
],
但它仍然失败并出现同样的错误
【问题讨论】:
-
遇到同样的问题 - 你最终以某种方式解决了这个问题吗?上面的链接没有解决我的问题。
-
不,对我来说也不行。你有解决办法吗?
-
找到任何解决方案了吗?
标签: angularjs unit-testing ionic-framework ionic3 jestjs