我有问题,我认为这不正常。
当我启动命令'ng test --watch = false'时,至少有一个测试错误(期望值错误),该命令因该错误而退出
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ulys-nav@0.0.1 test: `ng test --watch=false`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ulys-nav@0.0.1 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/martels3/.npm/_logs/2019-10-21T11_20_00_883Z-debug.log
但是,当我修正测试(正确的期望)时,每一个都是正常的(没有错误)。
这是我的karma.conf.js
const puppeteer = require('puppeteer');
process.env.CHROME_BIN = puppeteer.executablePath();
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false, // leave Jasmine Spec Runner output visible in browser
jasmine: {
random: false
}
},
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: ['Chrome', 'ChromeHeadless'],
customLaunchers: {
ChromeHeadlessCI: {
base: 'ChromeHeadless',
flags: ['--no-sandbox', '--disable-gpu']
}
},
singleRun: false,
captureTimeout: 210000,
browserDisconnectTolerance: 3,
browserDisconnectTimeout: 210000,
browserNoActivityTimeout: 210000
});
};
这个可怕的错误是正常现象吗? 因为当我在CI(bitRise)中启动此命令时,该命令因此退出了,我不想这样做!
答案 0 :(得分:0)
也许您仍然有问题。我认为即使不是最佳解决方案,我也为您提供解决方案。出现此类问题的原因是sourceMap
属性的配置。如果您在项目中搜索关键字,则会在angular.json
和tsconfig.json
在angular.json
中将其设置为false,在tsconfig.json
中将其设置为true。设置为true时,浏览器将断开连接,并且测试不起作用。因此解决方案是像这样配置您的命令:
ng test --source-map=false --watch=false
对我来说,这是有帮助的解决方案,因为sourceMap似乎有问题。与此GitHub问题https://github.com/karma-runner/karma/issues/3267相关,并解释了sourceMaps
是什么: