我为我的角度组件编写了测试用例。总共有11个我需要执行的测试用例。测试用例运行正常,但除了我执行的11个测试用例之外,我每次都会收到此错误。
错误是:
Chrome 66.0.3359 (Windows 10 0.0.0) ERROR
{
"message": "An error was thrown in afterAll\n[object ErrorEvent]\n[object ErrorEvent]\n[object ErrorEvent]\n[object ErrorEvent]",
"str": "An error was thrown in afterAll\n[object ErrorEvent]\n[object ErrorEvent]\n[object ErrorEvent]\n[object ErrorEvent]"
Chrome 66.0.3359 (Windows 10 0.0.0): Executed 12 of 12 ERROR (0.45 secs / 0.413 secs)
Chrome控制台是这样的:
12 specs, 0 failures, randomized with seed 84434Error during loading: [object ErrorEvent]Error during loading: [object ErrorEvent]Error during loading: [object ErrorEvent]Error during loading: [object ErrorEvent]
Component : Filter Component
should create
selectFilterValue should be called after setInitialFilterValues
setInitialFilterValues should be called on reset
ngOnint called, setInitialFilterValues should be called
ChromeLauncher
SPEC HAS NO EXPECTATIONS works
testService : Service
if data is valid then return sum of key
if data is undefined return undefined
if data is not empty return success
if data is empty return undefined
if data is empty then return sum of key
test week number of given date
test first date of the week
我只有11个测试用例可以运行并且它们正常运行但是,在chrome控制台上有12个规格正在执行,因为我没有在控制台上获得干净的输出。
我该如何解决这个问题?
编辑:
karma.conf.js
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular/cli'],
files: [
{pattern: '../assets-ts/tests/src/*.spec.ts', included: false},
{pattern: '**/*.spec.js', included: true}
],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma')
],
client:{
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
tsconfig.spec.ts
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/spec",
"baseUrl": "./",
"module": "commonjs",
"target": "es5",
"types": [
"jasmine",
"node"
]
},
"files": [
"test.ts"
],
"include": [
"../tests/**/*.spec.ts",
"**/*.spec.ts",
"**/*.d.ts"
]
}
答案 0 :(得分:0)
尝试从karma.conf中删除以下部分
`files: [
{pattern: '../assets-ts/tests/src/*.spec.ts', included: false},
{pattern: '**/*.spec.js', included: true}
],`