在对我的 karma.conf.js 进行更改以允许 Karma Coverage 之后,运行 karma 现在会失败。我不确定发生了什么。有什么想法吗?
process.env.NODE_ENV = 'test';
module.exports = function(config) {
config.set({
autoWatch: true,
browsers: ['Chrome'], //, 'Firefox', 'Safari'],
frameworks: ['jasmine'],
logLevel: config.LOG_INFO,
singleRun: false,
port: 9876,
colors: true,
concurrency: Infinity, // how many browser should be started simultaneous
files: [
'test/**/*Spec.js',
'src/**/*.js' //ADDED FOR COVERAGE
],
preprocessors: {
'test/**/*Spec.js' : ['babel', 'webpack', 'sourcemap'],
'src/**/*.js' : ['babel', 'webpack', 'sourcemap', 'coverage'] //ADDED FOR COVERAGE
},
reporters: ['progress', 'coverage'], //ADDED FOR COVERAGE
coverageReporter: { //ADDED FOR COVERAGE
type : 'html',
dir : 'coverage/'
},
webpack: {
devtool: 'inline-source-map',
resolve: {
extensions: ['', '.js', '.jsx'],
modulesDirectories: [
'node_modules'
]
},
module: {
loaders: [
{
test: /\.(js|jsx)$/,
exclude: /(node_modules)/,
loader: 'babel-loader'
},
{
test: /\.css$/,
loader: "style-loader!css-loader"
}
]
},
externals: {
'cheerio': 'window',
'react/addons': true,
'react/lib/ExecutionEnvironment': true,
'react/lib/ReactContext': true
}
},
webpackServer: {
noInfo: true //don't spam the console when running in karma!
},
plugins: [
"karma-babel-preprocessor",
"karma-chrome-launcher",
"karma-webpack",
"karma-sourcemap-loader",
"karma-jasmine",
'karma-coverage' //ADDED FOR COVERAGE
],
babelPreprocessor: {
options: {
presets: [
"latest",
"react-app"
],
sourceMap: 'inline',
plugins: [
"transform-object-rest-spread"
]
}
}
})
}
我收到以下错误(下面还有更多类似的错误)
27 12 2016 06:35:35.997:ERROR [karma]: { 错误: MemoryFileSystem.readFileSync (/Users/lancepoehler/Documents/workspaces/SolarAnalysisClient/node_modules/memory-fs/lib/MemoryFileSystem.js: 114:10) 在 MemoryFileSystem.readFile (/Users/lancepoehler/Documents/workspaces/SolarAnalysisClient/node_modules/memory-fs/lib/MemoryFileSystem.js:297:21) 在 doRead (/Users/lancepoehler/Documents/workspaces/SolarAnalysisClient/ node_modules/karma-webpack/lib/karma-webpack.js:201:29) 在 Plugin.readFile (/Users/lancepoehler/Documents/workspaces/SolarAnalysisClient/node_modules/karma-webpack/lib/karma-webpack.js:205: 5) 在_combinedTickCallback (internal/process/next_tick.js:67:7) at process._tickCallback (internal/process/next_tick.js:98:9) 代码:'ENOENT',errno:34,消息:'没有这样的文件或目录',路径:'/_karma_webpack_/src/components/Error.js' }