StackOverflow的大家好,
我被卡住了!我的ng test
失败了,尽管ng serve
毫无问题地构建并编译了Angular 6项目。我收到的错误如下:
另外,在Chrome发生故障之后,就像这样:
我几乎不了解发生了什么,但是由于build-street失败,这个问题阻止了成功的部署。
作为一个大菜鸟,我疯狂地尝试着应用与我的问题极为相似但无济于事的解决方案。这就是为什么我向你们寻求帮助!我尝试做PhantomJS does not work with Karma in Angular2 project;将来自polyfills.ts的import 'zone.js/dist/zone'
放在文件顶部;更新PhantomJS,什么不更新。
我的karma.conf.js如下:
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-phantomjs-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
/*...*/
browsers: ['Chrome', 'PhantomJS'],
singleRun: true
});
};
不知道是否有帮助,但是我的package.json看起来像这样:
{
"name": "isms-frontend",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"prepare": "patch-package"
},
"private": true,
"dependencies": {
"@angular/animations": "6.1.8",
"@angular/cdk": "^6.4.7",
"@angular/common": "6.1.8",
"@angular/compiler": "6.1.8",
"@angular/core": "6.1.8",
"@angular/forms": "6.1.8",
"@angular/http": "6.1.8",
"@angular/material": "^6.4.7",
"@angular/platform-browser": "6.1.8",
"@angular/platform-browser-dynamic": "6.1.8",
"@angular/router": "6.1.8",
"core-js": "^2.5.4",
"hammerjs": "^2.0.8",
"intl": "^1.2.5",
"ngx-window-core": "^1.0.84",
"rxjs": "6.3.2",
"rxjs-compat": "6.3.2",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.8.0",
"@angular-devkit/build-ng-packagr": "~0.8.0",
"@angular/cli": "~6.2.1",
"@angular/compiler-cli": "^6.1.0",
"@angular/language-service": "^6.1.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.3.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-phantomjs-launcher": "^1.0.4",
"ng-packagr": "^4.1.0",
"phantomjs-prebuilt": "^2.1.16",
"patch-package": "^5.1.1",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tsickle": ">=0.29.0",
"tslib": "^1.9.0",
"tslint": "~5.11.0",
"typescript": "~2.9.2"
}
}
请让我知道是否有更多信息可以帮助解决此问题。预先感谢您的宝贵时间!
答案 0 :(得分:0)
在经历了所有苦难之后,我发现我所要做的就是向ng test
传递一个参数,就像我的情况下ng test isms-frontend
一样。找到了 jorgjanke 的答案,来自https://github.com/angular/angular-cli/issues/12581