forked from Semantic-Org/Semantic-UI-React
-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.js
99 lines (93 loc) · 2.92 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
const { argv } = require('yargs')
const config = require('./config')
const webpackConfig = require('./webpack.config')
module.exports = (karmaConfig) => {
karmaConfig.set({
basePath: process.cwd(),
browsers: ['PhantomJS'],
singleRun: !argv.watch,
reporters: ['mocha', 'coverage'],
files: [
'./test/tests.bundle.js',
],
formatError(msg) {
let haveSeenStack = false
return msg
.split('\n')
.reduce((list, line) => {
// filter out node_modules
if (/~/.test(line)) return list
// indent the error beneath the it() message
let newLine = ' ' + line
if (newLine.includes('webpack:///')) {
if (haveSeenStack === false) {
const indent = newLine.slice(0, newLine.search(/\S/))
newLine = `\n${indent}Stack:\n${newLine}`
haveSeenStack = true
}
// remove webpack:///
newLine = newLine.replace('webpack:///', '')
// remove bundle location, showing only the source location
newLine = newLine.slice(0, newLine.indexOf(' <- '))
}
return list.concat(newLine)
}, [])
.join('\n')
},
frameworks: [
'phantomjs-shim',
'mocha',
],
coverageReporter: {
reporters: [
{ type: 'lcov', dir: 'coverage', subdir: '.' },
{ type: 'text-summary' },
],
includeAllSources: true,
},
preprocessors: {
// do not include 'coverage' preprocessor for karma-coverage
// code is already instrumented by babel-plugin-__coverage__
'**/*.bundle.js': ['webpack'],
},
client: {
mocha: {
reporter: 'html', // change Karma's debug.html to mocha web reporter
ui: 'bdd',
},
},
webpack: {
devtool: config.compiler_devtool,
module: Object.assign({}, webpackConfig.module, {
loaders: [
{
test: /sinon\.js$/,
loader: 'imports?define=>false,require=>false',
},
...webpackConfig.module.loaders,
],
}),
plugins: webpackConfig.plugins,
resolve: Object.assign({}, webpackConfig.resolve, {
alias: Object.assign({}, webpackConfig.resolve.alias, {
sinon: 'sinon/pkg/sinon',
// These are internal deps specific to React 0.13 required() by enzyme
// They shouldn't be requiring these at all, issues and fix proposed
// https://github.com/airbnb/enzyme/issues/285
'react/lib/ExecutionEnvironment': 'empty/object',
'react/lib/ReactContext': 'empty/object',
// this is a React 0.13 dep required by enzyme
// ignore it since we don't have it
'react/addons': 'empty/object',
}),
}),
},
webpackServer: {
progress: false,
stats: config.compiler_stats,
debug: true,
noInfo: false,
quiet: false,
},
})
}