-
Notifications
You must be signed in to change notification settings - Fork 200
/
karma.conf.cjs
96 lines (89 loc) · 2.49 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
const istanbul = require('rollup-plugin-istanbul');
const yargs = require('yargs');
module.exports = async function(karma) {
const builds = (await import('./rollup.config.js')).default;
const args = yargs
.option('verbose', {default: false})
.argv;
// Use the same rollup config as our dist files: when debugging (npm run dev),
// we will prefer the unminified build which is easier to browse and works
// better with source mapping. In other cases, pick the minified build to
// make sure that the minification process (terser) doesn't break anything.
const regex = args.watch ? /chartjs-chart-financial\.js$/ : /chartjs-chart-financial\.min\.js$/;
const output = builds[0].output.filter((v) => v.file.match(regex))[0];
const build = Object.assign({}, builds[0], {output: output});
const inputs = args.inputs || 'test/specs/**/*.js';
if (args.coverage) {
build.plugins.push(
istanbul({exclude: ['node_modules/**/*.js', 'package.json']})
);
}
karma.set({
browsers: (args.browsers || 'chrome,firefox').split(','),
// Explicitly disable hardware acceleration to make image
// diff more stable when ran on Travis and dev machine.
// https://github.com/chartjs/Chart.js/pull/5629
customLaunchers: {
chrome: {
base: 'Chrome',
flags: [
'--disable-accelerated-2d-canvas'
]
},
firefox: {
base: 'Firefox',
prefs: {
'layers.acceleration.disabled': true
}
}
},
frameworks: ['jasmine'],
reporters: ['progress', 'kjhtml'],
files: [
'node_modules/luxon/build/global/luxon.js',
'node_modules/chart.js/dist/chart.umd.js',
'node_modules/chartjs-adapter-luxon/dist/chartjs-adapter-luxon.umd.js',
'test/index.js',
'src/index.js'
].concat(inputs),
preprocessors: {
'test/specs/**/*.js': ['rollup'],
'test/index.js': ['rollup'],
'src/index.js': ['sources']
},
rollupPreprocessor: {
external: [
'chart.js',
'chart.js/helpers',
'chartjs-chart-financial',
],
output: {
format: 'umd',
globals: {
'chart.js': 'Chart',
'chart.js/helpers': 'Chart.helpers',
'chartjs-chart-financial': 'Chart.Financial'
}
}
},
customPreprocessors: {
sources: {
base: 'rollup',
options: build
}
},
browserify: {
debug: true
}
});
if (args.coverage) {
karma.reporters.push('coverage');
karma.coverageReporter = {
dir: 'coverage/',
reporters: [
{type: 'html', subdir: 'html'},
{type: 'lcovonly', subdir: (browser) => browser.toLowerCase().split(/[ /-]/)[0]}
]
};
}
};