由于无法在Jenkins机器上安装任何浏览器,我们必须在项目中使用PhantomJS。
当前的业力配置如下:
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('karma-phantomjs-launcher'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../coverage'),
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['PhantomJS'],
singleRun: true,
});
};
这之前没有任何问题。但是,在升级依赖关系并添加了更多测试之后->我们现在有了0出0的测试错误:
PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 0 of 0 ERROR (0.019 secs / 0 secs)
我已经尝试了其他主题(哑剧,检查测试中的特殊字符)中建议的许多方法,但仍然无法解决此问题。
可能是什么问题?测试可以打破吗?还是最新版本NG根本无法与最新(旧)版本的karma-phantom-js启动器一起使用。
package.json
供参考:
{
"name": "xx",
"version": "xx",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"production": "node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build --c=production",
"development": "node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build --c=development",
"test": "ng test",
"lint": "ng lint --type-check",
"fix": "tslint --type-check --project tsconfig.json --fix '{src,e2e}/**/*.ts' -t verbose",
"e2e": "ng e2e",
"local-test": "ng test --karma-config src/karma.conf.local.js"
},
"private": true,
"dependencies": {
"@angular/animations": "^7.2.13",
"@angular/cdk": "^7.3.7",
"@angular/common": "^7.2.13",
"@angular/compiler": "^7.2.13",
"@angular/core": "^7.2.13",
"@angular/flex-layout": "^7.0.0-beta.24",
"@angular/forms": "^7.2.13",
"@angular/http": "^7.2.13",
"@angular/material": "^7.3.7",
"@angular/platform-browser": "^7.2.13",
"@angular/platform-browser-dynamic": "^7.2.13",
"@angular/router": "^7.2.13",
"@ckeditor/ckeditor5-angular": "^1.1.0",
"@ckeditor/ckeditor5-build-decoupled-document": "^12.1.0",
"@ngx-translate/core": "^11.0.1",
"@ngx-translate/http-loader": "^4.0.0",
"core-js": "^2.6.5",
"rxjs": "~6.4.0",
"tslib": "^1.9.0",
"zone.js": "^0.8.29"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.13.8",
"@angular/cli": "^7.3.8",
"@angular/compiler-cli": "^7.2.13",
"@angular/language-service": "^7.2.13",
"@types/jasmine": "^3.3.12",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~11.13.6",
"codelyzer": "~5.0.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.5",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"karma-phantomjs-launcher": "^1.0.4",
"protractor": "~5.4.2",
"ts-node": "~8.1.0",
"tslint": "~5.16.0",
"typescript": "^3.2.4"
}
}