我正在尝试使用Karma和Jasmine测试我的Angular 7.2应用程序。它工作正常,除了一件事:当我单击测试名称时,它会刷新页面并再次执行所有测试。当发生故障并且我单击“规格列表”时,也会发生同样的情况。尽管单击测试名称应该只重做单击的测试,并且单击“规格列表”,但只能转到显示哪些通过和不通过的规格列表。
知道为什么吗?
karma.conf.js:
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
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'),
require('karma-mocha-reporter')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../coverage/gts-ui-extensions-rc'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: ['mocha', 'kjhtml'],
port: 4300,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
};
dev依赖项:
"devDependencies": {
"@angular-devkit/build-angular": "~0.13.0",
"@angular/cli": "~7.3.8",
"@angular/compiler": "^7.2.12",
"@angular/compiler-cli": "~7.2.0",
"@angular/language-service": "^7.2.12",
"@types/jasmine": "^3.3.12",
"@types/jasminewd2": "^2.0.6",
"@types/node": "^11.13.0",
"codelyzer": "^5.0.0",
"jasmine-core": "^3.4.0",
"jasmine-spec-reporter": "^4.2.1",
"karma": "^4.0.1",
"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-mocha-reporter": "^2.2.5",
"protractor": "^5.4.2",
"ts-node": "^8.0.3",
"tslint": "^5.15.0",
"typescript": "3.1.1",
"webpack": "^4.29.6"
}
某些脚本将<a href='#'> </a>
链接重定向到主页,而默认情况下什么也不会发生。
此问题正在此处解决:jasmine issues 1775
查看对此请求的更改:pull request 1807
一种临时解决方案是将pull request 1807更改应用于此文件:node_modules \ karma-jasmine-html-reporter \ src \ lib \ html.jasmine.reporter.js