正如标题所暗示的,当我的套件中的测试失败时,我希望能够看到行号。我依赖于karma-tap
插件、tap
框架和dots
记者。
一点上下文:源映射正常工作,因此测试文件中抛出的异常报告正确的行以及堆栈跟踪。但是,当基本测试失败时,会输出“失败”消息,而没有任何关于线路或模块的信息。
Chrome 50.0.2661 (Mac OS X 10.11.4) should be equal FAILED
{
"operator": "equal",
"expected": 0,
"actual": 1
}
Chrome 50.0.2661 (Mac OS X 10.11.4) should be equal FAILED
{
"operator": "equal",
"expected": 0,
"actual": 1
}
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
...........................
我最初的想法是这只是 Tap 的一个限制,但我无法想象这是真的。我的完整 Karma 配置如下所示。配置中是否有某些内容会导致测试期间的行号输出失败?
{
plugins: [
require('karma-webpack'),
require('karma-tap'),
require('karma-chrome-launcher'),
require('karma-sourcemap-loader')
],
basePath: '',
frameworks: [ 'tap' ],
files: [
'tests.bootstrap.js',
],
preprocessors: {
'src/**/*.js': ['webpack', 'sourcemap'],
'tests.bootstrap.js': [ 'webpack', 'sourcemap' ]
},
webpack: {
devtool: 'inline-source-map',
externals: {
cheerio: 'window',
'react/lib/ExecutionEnvironment': true,
'react/lib/ReactContext': true,
'text-encoding': 'window',
'react/addons': true,
},
module: {
preLoaders: [
{
test: /\.js/,
exclude: /node_modules/,
loader: 'babel'
},
{
test: /\.js$/,
include: [
path.resolve(__dirname, 'src/components/'),
//path.resolve(__dirname, 'src/containers/'),
path.resolve(__dirname, 'src/layouts/'),
path.resolve(__dirname, 'src/reducers/'),
path.resolve(__dirname, 'src/stores/'),
path.resolve(__dirname, 'src/util/')
],
exclude: /-container\.js/,
loader: 'isparta'
}
],
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: "source-map-loader"
}, {
test: /\.(png|jpg|jpeg|gif|woff|woff2)$/,
loader: 'url?limit=25000',
include: path.resolve(__dirname, 'src')
}, {
test: /\.svg$/,
loader: 'file-loader'
}
]
},
node : {
fs: 'empty'
},
resolve: {
modulesDirectories: ['src', 'node_modules']
}
},
webpackMiddleware: {
noInfo: true
},
reporters: [ 'dots' ],
client: {
captureConsole: false
},
port: 9878,
colors: true,
logLevel: config.LOG_DEBUG,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
}