forked from kurkle/chartjs-chart-matrix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.cjs
99 lines (89 loc) · 2.45 KB
/
karma.conf.cjs
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 istanbul = require('rollup-plugin-istanbul');
const resolve = require('@rollup/plugin-node-resolve').nodeResolve;
const json = require('@rollup/plugin-json');
const env = process.env.NODE_ENV;
module.exports = async function(karma) {
const builds = (await import('./rollup.config.js')).default;
const regex = karma.autoWatch ? /chartjs-chart-matrix\.cjs$/ : /chartjs-chart-matrix\.min\.js$/;
const build = builds.filter(v => v.output.file && v.output.file.match(regex))[0];
if (!build) {
throw new Error('could not find build for output matching ' + regex);
}
if (env === 'test') {
build.plugins = [
resolve(),
json(),
istanbul({exclude: ['node_modules/**/*.js', 'package.json']})
];
}
karma.set({
browsers: ['chrome', 'firefox'],
frameworks: ['jasmine'],
reporters: ['spec', 'kjhtml'],
logLevel: karma.LOG_WARN,
files: [
{pattern: './test/fixtures/**/*.js', included: false},
{pattern: './test/fixtures/**/*.png', included: false},
'node_modules/chart.js/dist/chart.umd.js',
'node_modules/chartjs-adapter-date-fns/dist/chartjs-adapter-date-fns.bundle.js',
{pattern: 'src/index.js', type: 'js'},
'test/index.js',
'test/specs/**/*.js'
],
customLaunchers: {
chrome: {
base: 'Chrome',
flags: [
'--disable-background-timer-throttling',
'--disable-backgrounding-occluded-windows',
'--disable-renderer-backgrounding'
]
},
firefox: {
base: 'Firefox',
prefs: {
'layers.acceleration.disabled': true
}
}
},
preprocessors: {
'test/index.js': ['rollup'],
'src/index.js': ['sources']
},
rollupPreprocessor: {
plugins: [
resolve()
],
output: {
name: 'test',
format: 'umd',
sourcemap: karma.autoWatch ? 'inline' : false
}
},
customPreprocessors: {
fixtures: {
base: 'rollup',
options: {
output: {
format: 'iife',
name: 'fixture',
}
}
},
sources: {
base: 'rollup',
options: build
}
}
});
if (env === 'test') {
karma.reporters.push('coverage');
karma.coverageReporter = {
dir: 'coverage/',
reporters: [
{type: 'html', subdir: 'html'},
{type: 'lcovonly', subdir: (browser) => browser.toLowerCase().split(/[ /-]/)[0]}
]
};
}
};