我正在处理一个角度应用程序,当我运行"ng test"命令时,它显示一些错误并说"断开连接(0 次(,因为 30000 毫秒内没有消息。'.我尝试更新业力、茉莉花包并进行了"npm 安装",但仍然没有任何帮助。以下是依赖包和 karma.conf.js 文件。我在这里错过了什么吗?是否需要升级任何软件包?
"devDependencies": {
"@angular-devkit/build-angular": "~0.13.0",
"@angular/animations": "^5.0.0",
"@angular/cli": "~7.3.2",
"@angular/compiler-cli": "~7.2.0",
"@angular/language-service": "~7.2.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.4.2",
"husky": "^0.13.4",
"jasmine-core": "^2.5.2",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^3.1.4",
"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",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.2.2",
"typescript-formatter": "^7.2.2",
"webpack": "^4.9.2"
},
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
},
files: [
{
pattern: 'specs.ts',
included: false
}
],
preprocessors: {
},
mime: {
'text/x-typescript': ['ts', 'tsx']
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, 'coverage'), reports: ['html', 'lcovonly'],
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true,
thresholds: {
statements: 80,
lines: 80,
branches: 80,
functions: 80
}
},
reporters: config.angularCli && config.angularCli.codeCoverage
? ['progress', 'coverage-istanbul']
: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
customLaunchers: {
ChromeHeadlessCI: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
},
singleRun: false,
restartOnFileChange: true
});
};
> karma.conf.js 中的以下配置选项可能会有所帮助:
module.exports = function (config) {
config.set({
//***
browserNoActivityTimeout: 60000,
browserDisconnectTimeout: 60000
//***
});
};
例如,这在运行 karma-parallel 时很有帮助,它会启动许多浏览器,并且所有浏览器都需要时间来初始化......
有关参考,请参阅 karma 配置文件文档:https://karma-runner.github.io/4.0/config/configuration-file.html