Angular Karma看不到带u的目录下的规范文件(示例:ui)
当我运行ng测试时。Karma查找所有等级库文件,但不包括带u的文件夹中的文件(例如:sidebar) 这是karma.conf.js文件:Angular Karma看不到带u的目录下的规范文件(示例:ui),angular,karma-jasmine,Angular,Karma Jasmine,当我运行ng测试时。Karma查找所有等级库文件,但不包括带u的文件夹中的文件(例如:sidebar) 这是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(
// 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/themes'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
};
下面是test.ts文件上下文筛选器:
const context = require.context('./', true, /\.spec\.ts$/);
检查
tsconfig.spec.json
并注意文件
、包含
、和排除
数组,确保未排除这些文件夹
在
test.ts
中,有一个context
属性,可能它忽略了以\
开头的文件夹以及'/'以下是我的上下文过滤器:const context=require.context('./',true,/\.spec.ts$/);如何修复它?请尝试const-context=require.context('./\u',true,/\.spec\.ts$/)
并查看是否仅运行带有{u'的文件夹中的单元测试。如果是的话,我想就是这样。但如果可能的话,如果不需要的话,我会删除文件夹中的u。