Sun*_*ani 5 unit-testing karma-jasmine angular
在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'),
require('karma-chrome-launcher'),
require('karma-junit-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma'),
require('karma-jasmine-html-reporter')
],
client: {
clearContext: false, // leave Jasmine Spec Runner output visible in browser
captureConsole: false
},
junitReporter: {
outputDir: 'reports/junit/',
outputFile: 'TESTS-xunit.xml',
useBrowserName: false,
suite: '' // Will become the package name attribute in xml testsuite element
},
coverageIstanbulReporter: {
reports: ['html', 'lcovonly', 'text-summary'],
dir: './reports/coverage',
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: ['progress', 'junit', 'kjhtml'],
port: 9876,
colors: true,
// Level of logging, can be: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1618 次 |
| 最近记录: |