forked from searchkit/searchkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.js
executable file
·58 lines (53 loc) · 1.61 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
var path = require("path");
var WebpackConfig = require('webpack-config');
// Karma configuration here
module.exports = function (config) {
var needsCoverage = config.reporters.indexOf("coverage") > -1
var needsJunit = config.reporters.indexOf("junit") > -1
if(needsCoverage && process.env.COVERALLS_REPO_TOKEN) {
config.reporters.push("coveralls")
}
config.reporters.push("jasmine-diff")
config.set({
port: 3334,
browsers: ['PhantomJS'],
// singleRun: true, //just run once by default
frameworks: ['jasmine'], //use jasmine as framework
files: [
path.join(__dirname, 'node_modules', 'phantomjs-polyfill', 'bind-polyfill.js'), // To enable PhantomJS to render React components
'webpack.tests.js' //test files
],
preprocessors: {
'webpack.tests.js': ['webpack', 'sourcemap']
}
})
var webpack = new WebpackConfig().extend("webpack.test.config")
if(needsJunit){
config.set({
junitReporter: {
outputDir: path.join(process.env.CIRCLE_TEST_REPORTS || '$CIRCLE_TEST_REPORTS', "karma", "junit.xml"),
useBrowserName: false // add browser name to report and classes names
}
})
}
if(needsCoverage){
webpack = webpack.merge({
module:{
postLoaders: [{
test: /\.(js|tsx?)/,
exclude: /(test|node_modules|bower_components)/,
loader: 'istanbul-instrumenter'
}]
}
})
config.set({
coverageReporter: {
type: 'lcov', // lcov or lcovonly are required for generating lcov.info files
dir: 'coverage/'
}
})
}
config.set({
webpack:webpack
})
};