forked from hcfyapp/crx-selection-translate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.js
68 lines (62 loc) · 1.67 KB
/
karma.conf.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const path = require( 'path' ) ,
webpack = require( 'webpack' ) ,
c = require( './webpack.config.js' );
c.entry = {}; // 清空 entry
delete c.watch; // 关闭 watch 模式
c.devtool = '#inline-source-map';
const babelLoaderConfig = c.module.loaders.shift();
babelLoaderConfig.exclude.push( path.resolve( 'src/' ) );
// 必须告诉 isparta 我使用了哪些 babel 设置,见 https://github.com/deepsweet/isparta-loader/issues/10
c.isparta = {
embedSource : true ,
noAutoWrap : true ,
babel : babelLoaderConfig.query
};
c.plugins.splice( 0 , 3 ); // 清空 webpack 优化
c.plugins.pop(); // 清空开发模式定义
c.plugins.push( new webpack.DefinePlugin( { // 切换为测试环境
'process.env.NODE_ENV' : "'testing'"
} ) );
c.module.preLoaders = [
babelLoaderConfig ,
{
test : /\.js$/ ,
include : path.resolve( 'src/' ) ,
loader : 'isparta'
}
];
module.exports = function ( config ) {
config.set( {
basePath : '' ,
frameworks : [ 'jasmine' ] ,
files : [
'tests/index.js'
] ,
preprocessors : {
'tests/index.js' : [ 'webpack' , 'sourcemap' ]
} ,
webpack : c ,
reporters : [ 'progress' , 'coverage' ] ,
coverageReporter : {
dir : 'coverage' ,
reporters : [
{
type : 'html' ,
subdir : function ( browser ) {
return 'html/' + browser.toLowerCase().split( /[ /-]/ )[ 0 ];
}
} ,
{
type : 'lcov' ,
subdir : 'lcov'
}
]
} ,
port : 9876 ,
colors : true ,
logLevel : config.LOG_INFO ,
autoWatch : false ,
browsers : [ 'Firefox' , 'Chrome' , 'IE' , 'PhantomJS' ] ,
singleRun : true
} )
};