在Chrome中运行单元测试时,我无法获得karma茉莉Html报告。Chrome正在加载组件的html,但未显示测试结果。
但是我在终端本身中获得测试结果。我尝试在karma.config.js中添加以下内容,但出现错误。
在Pulgins中-> require('karma-jasmine-html-reporter')在报告者中-> kjhtml
{
"message": "Uncaught TypeError: env.stopOnSpecFailure is not a function\nat node_modules/karma-jasmine-html-reporter/src/lib/adapter.js:26:7\n\nTypeError: env.stopOnSpecFailure is not a function\n at node_modules/karma-jasmine-html-reporter/src/lib/adapter.js:26:7\n at node_modules/karma-jasmine-html-reporter/src/lib/adapter.js:76:3",
"str": "Uncaught TypeError: env.stopOnSpecFailure is not a function\nat node_modules/karma-jasmine-html-reporter/src/lib/adapter.js:26:7\n\nTypeError: env.stopOnSpecFailure is not a function\n at node_modules/karma-jasmine-html-reporter/src/lib/adapter.js:26:7\n at node_modules/karma-jasmine-html-reporter/src/lib/adapter.js:76:3"
Run Code Online (Sandbox Code Playgroud)
}
以下是package.json中的版本
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "^4.1.0",
"karma": "~2.0.0",
"karma-chrome-launcher": "^2.2.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "^1.1.0",
"karma-jasmine-html-reporter": "^1.1.0",
Run Code Online (Sandbox Code Playgroud)
以下是Karma.config.js
// Karma配置文件,请参阅链接以获取更多信息// https://karma-runner.github.io/1.0/config/configuration-file.html
process.env.CHROME_BIN = require('puppeteer').executablePath();
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'), …Run Code Online (Sandbox Code Playgroud)