forked from web3/web3.js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
karma.conf.js
68 lines (62 loc) · 1.94 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
process.env.MOZ_HEADLESS = 1;
if (!process.env.TRAVIS){
process.env.CHROME_BIN = require('puppeteer').executablePath();
}
// BROWSER_BUNDLE_TEST is set for an un-browserified check that both bundles load correctly.
// BROWSER_BUNDLE_TEST is not set for the e2e unit tests, which check that bundle internals are ok.
function getTestFiles(){
switch (process.env.BROWSER_BUNDLE_TEST){
case 'publishedDist': return ["packages/web3/dist/web3.min.js", "test/e2e.minified.js"]
case 'gitRepoDist': return ["dist/web3.min.js", "test/e2e.minified.js"]
default: return ["test/**/e2e*.js"]
}
}
// Only loads browserified preprocessor for the logic unit tests so we can `require` stuff.
function getPreprocessors(){
if (!process.env.BROWSER_BUNDLE_TEST){
return { 'test/**/e2e*.js': [ 'browserify' ] }
}
}
module.exports = function (config) {
var configuration = {
frameworks: [
'mocha',
'browserify'
],
files: getTestFiles(),
preprocessors: getPreprocessors(),
plugins: [
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-mocha',
'karma-browserify',
'karma-spec-reporter'
],
reporters: ['spec'],
port: 9876, // karma web server port
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: [
'ChromeHeadless',
'FirefoxHeadless'
],
customLaunchers: {
FirefoxHeadless: {
base: 'Firefox',
flags: ['-headless'],
},
Chrome_travis_ci: {
base: 'Chrome',
flags: ['--no-sandbox']
}
},
};
if(process.env.TRAVIS) {
configuration.browsers = [
'Chrome_travis_ci',
'FirefoxHeadless'
];
}
config.set(configuration);
};