-
Notifications
You must be signed in to change notification settings - Fork 30
/
karma.conf.js
97 lines (94 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
const packageJson = require('./package.json');
/* eslint-disable no-process-env */
let job = process.env.JOB_NUMBER || Date.now();
let browsers = [ 'ChromeHeadless' ];
let build = 'localbuild';
let branch = 'local';
let startConnect = false;
const reporters = [ 'progress', 'coverage' ];
const tags = [ `${ packageJson.name }@${ packageJson.version }` ];
const frameworks = [ 'mocha' ];
const debug = Boolean(process.env.npm_config_debug);
if (process.env.SAUCE_USERNAME) {
browsers = [ 'SauceEdgeLatest', 'SauceInternetExplorerTen', 'SauceSafariLatest' ];
tags.push(`${ process.env.SAUCE_USERNAME }@${ branch }`);
reporters.push('saucelabs');
startConnect = true;
} else if (process.env.APPVEYOR) {
browsers = [ 'Firefox', 'ChromeHeadless', 'IE' ];
} else if (process.env.CI) {
browsers = [ 'FirefoxHeadless', 'ChromeHeadlessNoSandbox' ];
} else if (!process.env.KARMA_MANUAL) {
browsers = [];
frameworks.push('detectBrowsers');
}
if (process.env.APPVEYOR) {
branch = process.env.APPVEYOR_REPO_BRANCH;
build = `appveyor@${ process.env.APPVEYOR_JOB_NUMBER }`;
job = process.env.APPVEYOR_JOB_NUMBER;
}
/* eslint-enable */
tags.push(build);
module.exports = function configureKarma(config) {
config.set({
basePath: '',
browsers,
singleRun: true,
logLevel: debug ? config.LOG_DEBUG : config.LOG_INFO,
frameworks,
files: [ `${ packageJson.name }.test.js` ],
reporters,
coverageReporter: {
type: 'lcov',
dir: 'coverage',
},
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: [ '--no-sandbox' ],
},
FirefoxHeadless: {
base: 'Firefox',
flags: [ '-headless' ],
},
SauceSafariLatest: {
base: 'SauceLabs',
browserName: 'Safari',
platform: 'OS X 10.11',
},
SauceInternetExplorerTen: {
base: 'SauceLabs',
browserName: 'Internet Explorer',
version: 10,
},
SauceEdgeLatest: {
base: 'SauceLabs',
browserName: 'MicrosoftEdge',
},
},
detectBrowsers: {
enabled: true,
usePhantomJS: false,
postDetection(detectedBrowsers) {
if (detectedBrowsers.length === 0) {
/* eslint-disable no-console, no-process-exit */
console.log('**********************************');
console.log('**************WARNING*************');
console.log('**********************************');
console.log('Karma has been unable to detect a browser on your system');
console.log('Karma will now exit(0). If you have a browser you\'d like to test');
console.log('please run `env KARMA_MANUAL=1 karma`, and manually load up a browser');
process.exit(0);
/* eslint-enable */
}
return detectedBrowsers;
},
},
sauceLabs: {
testName: packageJson.name,
tunnelIdentifier: job,
startConnect,
tags,
},
});
};