gpt4 book ai didi

Angular 6 测试用例失败并显示不相关的错误消息

转载 作者:太空狗 更新时间:2023-10-29 17:21:11 25 4
gpt4 key购买 nike

我已将 Angular 4 应用程序迁移到 Angular 6,现在测试用例失败并在终端中显示以下错误消息,并在浏览器上显示成功。此外,有时测试用例会在不显示任何错误消息的情况下通过。所以我们可以说我在运行 ng 测试时有 60% 的时间遇到​​以下错误。

Chrome 67.0.3396 (Linux 0.0.0) ERROR
{
"message": {
"isTrusted": true
},
"str": "[object ErrorEvent]"
}

我已经尝试升级和降级 jasmine 和 jasmine-core

这是我的 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 个。

最佳答案

我通过将这些导入添加到 test.ts 文件中解决了这个问题:

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';

不知 Prop 体原因。但它为我做到了。

注意:我使用 mocha 而不是 jasmine 进行测试,所以我想你需要为 'zone.js 更改 'zone.js/dist/mocha-patch'/dist/ Jasmine 补丁'

关于Angular 6 测试用例失败并显示不相关的错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51807914/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com