Skip to content

Commit a955f9d

Browse files
committed
Disable hardware acceleration for unit tests
Explicitly disable hardware acceleration to make image diff more stable when ran on Travis (CPU) and dev machine (usually GPU).
1 parent 7a5515b commit a955f9d

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

karma.conf.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,27 @@
33
module.exports = function(karma) {
44
var args = karma.args || {};
55
var config = {
6-
browsers: ['Firefox'],
76
frameworks: ['browserify', 'jasmine'],
87
reporters: ['progress', 'kjhtml'],
8+
browsers: ['chrome', 'firefox'],
9+
10+
// Explicitly disable hardware acceleration to make image
11+
// diff more stable when ran on Travis and dev machine.
12+
// https://github.com/chartjs/Chart.js/pull/5629
13+
customLaunchers: {
14+
chrome: {
15+
base: 'Chrome',
16+
flags: [
17+
'--disable-accelerated-2d-canvas'
18+
]
19+
},
20+
firefox: {
21+
base: 'Firefox',
22+
prefs: {
23+
'layers.acceleration.disabled': true
24+
}
25+
}
26+
},
927

1028
preprocessors: {
1129
'./test/jasmine.index.js': ['browserify'],
@@ -24,15 +42,7 @@ module.exports = function(karma) {
2442

2543
// https://swizec.com/blog/how-to-run-javascript-tests-in-chrome-on-travis/swizec/6647
2644
if (process.env.TRAVIS) {
27-
config.browsers.push('chrome_travis_ci');
28-
config.customLaunchers = {
29-
chrome_travis_ci: {
30-
base: 'Chrome',
31-
flags: ['--no-sandbox']
32-
}
33-
};
34-
} else {
35-
config.browsers.push('Chrome');
45+
config.customLaunchers.chrome.flags.push('--no-sandbox');
3646
}
3747

3848
if (args.coverage) {

0 commit comments

Comments
 (0)