为什么因果报应跳过我的有效单元测试



我在Angular 10项目中与Karma合作。我正在尝试测试选择器,通过运行npm run test-report可以看到文件显示在所有文件列表中,但当我运行测试时,我可以看到文件被跳过。我甚至试着在描述之前放一个f,但因果报应仍然跳过了它。这个测试与我运行过的其他测试几乎相同,所以很令人困惑。请参阅下面的相关selector.spec文件代码和我的karma配置。

import { SupportState } from './reducers';
import { supportConfig } from './support.constant';
import * as selectors from './support.selectors';
fdescribe('SupportSelectors', () => {
let supportConfiguration;
let myFaqs;
let state: SupportState;
beforeEach(() => {
supportConfiguration = supportConfig;
myFaqs = {
answer: "<p>Once signed in to Member Online Services, you can find out if you have coverage for Durable Medica;",
question: "Am I covered for Durable Medical Equipment (DME) such as breast pumps, sleep apnea machines and orthotics???",
id: 15,
name: "Benefits"
}
state = {
config: supportConfiguration,
faqs: myFaqs,
category: myFaqs.name,
error: undefined
};
it('should return the configuration for Support', () => {
expect(selectors.selectSupportConfig.projector(state)).toEqual(supportConfiguration);
});
it('should return faqs', () => {
expect(selectors.selectSupportFAQs.projector(state)).toEqual(myFaqs);
});
it('should return category', () => {
expect(selectors.selectSupportFAQCategory.projector(state)).toEqual(myFaqs.name);
});
});
});

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'),
],
client: {
clearContext: false, // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, './coverage/member-portal'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true,
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
browserNoActivityTimeout: 60000,
browserDisconnectTimeout: 60000,
autoWatch: true,
browsers: ['Chrome', 'ChromeHeadless'],
singleRun: false,
customLaunchers: {
ChromeHeadless: {
base: 'Chrome',
flags: ['--headless', '--disable-gpu', '--no-sandbox', '--remote-debugging-port=9222'],
},
},
restartOnFileChange: true,
});
};

看起来您的it()期望值嵌套在beforeEach块中。它们应该是beforeEach的对等体,或者直接位于最近的describe之下。

相关内容

最新更新