我已经将Angular 4应用程序迁移到了Angular 6,现在测试用例在终端中出现以下错误消息失败,并且在浏览器上显示成功。另外,有时测试用例通过而未显示任何错误消息。因此,可以说我在执行ng test时有60%的时间出现错误。
Chrome 67.0.3396 (Linux 0.0.0) ERROR
{
"message": {
"isTrusted": true
},
"str": "[object ErrorEvent]"
}
我曾尝试升级和降级茉莉花和茉莉花芯
这是我的package.json
{
"name": "anonymos",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^6.0.3",
"@angular/common": "^6.0.3",
"@angular/compiler": "^6.0.3",
"@angular/core": "^6.0.3",
"@angular/forms": "^6.0.3",
"@angular/http": "^6.0.3",
"@angular/platform-browser": "^6.0.3",
"@angular/platform-browser-dynamic": "^6.0.3",
"@angular/router": "^6.0.3",
"@ng-bootstrap/ng-bootstrap": "^2.2.0",
"angular-cookie": "^4.1.0",
"angular-in-memory-web-api": "^0.6.0",
"angular2-cookie": "^1.2.6",
"angular2-recaptcha": "1.1.0",
"body-parser": "1.18.3",
"bootstrap": "4.1.2",
"cookie-parser": "1.4.3",
"core-js": "^2.5.4",
"es6-shim": "0.35.3",
"http-server": "0.11.1",
"jquery": "^3.3.1",
"js-base64": "2.4.8",
"node-sass": "^4.9.2",
"popper.js": "^1.14.3",
"reflect-metadata": "0.1.12",
"rxjs": "^6.0.0",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.6.8",
"@angular/cli": "~6.0.8",
"@angular/compiler-cli": "^6.0.3",
"@angular/language-service": "^6.0.3",
"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3",
"@types/jquery": "3.3.4",
"@types/node": "^8.10.21",
"codelyzer": "~4.2.1",
"jasmine": "^3.1.0",
"jasmine-core": "^2.9.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^2.0.4",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.0",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.3.0",
"ts-node": "~5.0.1",
"tslint": "~5.9.1",
"typescript": "~2.7.2"
}
}
如果需要其他任何调试方法,请告诉我。 我无法上传测试用例,因为它们大约有350个。
答案 0 :(得分:0)
我通过将以下导入添加到test.ts文件中解决了这个问题:
<hr class="star-light">
不知道确切原因。但这对我有用。
注意:我使用的是摩卡咖啡,而不是茉莉花,因此我想您需要将import 'zone.js/dist/long-stack-trace-zone';
import 'zone.js/dist/proxy.js';
import 'zone.js/dist/sync-test';
import 'zone.js/dist/mocha-patch';
import 'zone.js/dist/async-test';
import 'zone.js/dist/fake-async-test';
更改为'zone.js/dist/mocha-patch'