我无法理解为什么我的业力测试用例在固定测试用例之后会重新运行多次。
已断开连接,因为在50000毫秒内没有消息。Chrome 75.0.3770(Windows 10.0.0):执行131,共131断开连接(1分钟9.028秒/ 18.285秒)
Chrome 75.0.3770(Windows 10.0.0):执行131,共131个已断开连接(47.273秒/ 18.169秒)
Chrome 75.0.3770(Windows 10.0.0):执行131,共131个已断开连接(1分钟9.028秒/ 18.285秒)
Chrome 75.0.3770(Windows 10.0.0):执行131,共131个已断开连接(47.273秒/ 18.169秒)
Chrome 75.0.3770(Windows 10.0.0):已执行97,共251个已断开连接(22.07秒/19.87秒)
Chrome 75.0.3770(Windows 10.0.0):执行131,共131个已断开连接(1分钟9.028秒/ 18.285秒)
Chrome 75.0.3770(Windows 10.0.0):执行131成功131,成功(0秒/ 17.406秒)
Chrome 75.0.3770(Windows 10.0.0):执行239项成功,共239项(0秒/20.912秒)中的239]
下面是karma.conf.js的配置
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
const { join } = require('path');
const { constants } = require('karma');
module.exports = () => {
return {
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: join(__dirname, '../../coverage'),
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: constants.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: true,
};
};
当我将singleRun更改为false并使用ng test执行测试用例时,它工作正常,问题仅在将其更改为true时。
[我看了几个博客,并尝试通过添加更多配置来解决它,例如
browserNoActivityTimeout: 50000,
captureTimeout: 60 * 1000,
// captureTimeout: 210000,
browserDisconnectTolerance: 1,
// browserDisconnectTimeout: 210000,
// browserNoActivityTimeout: 210000
但是对我没有任何作用。
下面是devDependencies中的配置(我正在使用angular cli版本8)
"devDependencies": {
"@angular-devkit/build-angular": "0.800.3",
"@angular-devkit/build-ng-packagr": "0.800.3",
"@angular/cli": "^8.0.3",
"@angular/compiler-cli": "~8.0.0",
"@angular/language-service": "^6.1.0",
"@ngrx/store-devtools": "6.0.1",
"@nrwl/schematics": "~8.0.0",
"@ruf/schematics": "next",
"@ruf/wrench": "next",
"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^8.10.10",
"codelyzer": "5.1.0",
"dotenv": "6.2.0",
"jasmine-core": "~3.4.0",
"jasmine-marbles": "0.3.1",
"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.2",
"ngrx-store-freeze": "0.2.4",
"prettier": "1.16.4",
"protractor": "~5.3.0",
"scss-bundle": "^2.1.2",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.4.5",
"istanbul-instrumenter-loader": "^3.0.1",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^3.0.4",
"source-map-loader": "^0.2.4"
}
请提出建议!!!!
我通过监视其中设置了location.href
的功能解决了上述问题。
[location.href
导致页面使用不同的URL加载,并且由于业障一次又一次地运行。