Webpack 1.3.1
Babel 5.8.35
巴马1.1.2
第一次设置它时,我的一些文件没有被加载,看起来他们遇到了某些错误,但是我无法弄清楚输出中没有错误消息的确切内容。
我不确定我是否正确地做到了,这是我的Karma配置:
const webpack = require('webpack');
const webpackConfig = require('../tools/webpack.config.babel');
const RewirePlugin = require("rewire-webpack");
const path = require('path');
const argv = require('minimist')(process.argv.slice(2));
const RELEASE = !!argv.release;
const DEBUG = !!argv.debug;
const BROWSERS = argv.browsers;
module.exports = function(config) {
function getReporters() {
return ['junit', 'progress'];
}
function getBrowsers() {
let browsers = ['PhantomJS'];
if (BROWSERS) {
return BROWSERS.split(',');
}
if (RELEASE) {
browsers = ['Chrome', 'Firefox', 'IE'];
} else if (DEBUG) {
browsers = ['Chrome'];
}
return browsers;
}
function getFiles() {
let files = [
'node_modules/jquery/dist/jquery.js',
'node_modules/jquery-ui/js/jquery-ui.js',
'test/tests.jsx'
];
return files;
}
function getPreprocessors() {
return {
'test/tests.jsx': ['webpack', 'sourcemap'],
'src/**/*(js|jsx)': ['webpack', 'sourcemap']
};
}
function configureWebpackConfig() {
webpackConfig.plugins = [];
webpackConfig.plugins.push(new RewirePlugin());
webpackConfig.devtool = 'inline-source-map';
return webpackConfig;
}
config.set({
basePath: path.join(__dirname, '../'),
files: getFiles(),
singleRun: false,
preprocessors: getPreprocessors(),
webpack: configureWebpackConfig(),
webpackServer: {
stats: {
colors: true
}
},
webpackMiddleware: {
// webpack-dev-middleware configuration
// i. e.
noInfo: true
},
browserNoActivityTimeout: 1000000,
// coverage reporter generates the coverage
reporters: ['junit', 'progress'],
autoWatch: false,
frameworks: [
'jasmine',
'jasmine-matchers'
],
browsers: getBrowsers(),
plugins: [
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-phantomjs-launcher-nonet',
'karma-ie-launcher',
'karma-jasmine',
'karma-jasmine-matchers',
'karma-webpack',
'karma-junit-reporter',
'karma-sourcemap-loader'
],
customLaunchers: {
IE11: {
base: 'IE',
'x-ua-compatible': "IE=EmulateIE11"
}
},
phantomjsLauncher: {
cmd: {
win32: path.join(__dirname, '../node_modules/phantomjs/lib/phantom/bin/phantomjs.exe')
}
}
});
};
我的目录结构:
project
|
└───node_modules
│
└───src
│ │ jsx files
│ |
│ ├─── __tests__
│ │ │ test files
│ │ │ ...
│ │
└───test
| │ tests.jsx
│ │
│ │
└───config
| |
| | karma.js
我的tests.jsx
const testsContext = require.context("../src", true, /^.*\.(spec|integration-spec)$/);
console.log('found ' + testsContext.keys().length + " tests");
testsContext.keys().forEach(function(k) {
console.log('executing ' + k + " test");
console.log(testsContext);
testsContext(k);
});
module.exports = testsContext;
我能够确定哪些人没有得到适当的要求,但我无法弄清楚原因。这就是我得到的:
PhantomJS 2.1.1(Windows 7 0.0.0):执行0 of 0 ERROR(0.004秒/ 0秒)