forked from mochajs/mocha
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkarma.conf.js
More file actions
131 lines (122 loc) · 3.47 KB
/
karma.conf.js
File metadata and controls
131 lines (122 loc) · 3.47 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
'use strict';
function addSauceTests(cfg) {
cfg.reporters.push('saucelabs');
cfg.customLaunchers = {
ie8: {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 7',
version: '8.0'
},
chrome: {
base: 'SauceLabs',
browserName: 'chrome',
platform: 'Windows 8',
version: 'latest'
},
edge: {
base: 'SauceLabs',
browserName: 'MicrosoftEdge',
platform: 'Windows 10',
version: 'latest'
},
firefox: {
base: 'SauceLabs',
browserName: 'firefox',
platform: 'Windows 8.1',
version: 'latest'
},
safari: {
base: 'SauceLabs',
browserName: 'safari',
platform: 'OS X 10.11',
version: 'latest'
}
};
cfg.browsers = cfg.browsers.concat(Object.keys(cfg.customLaunchers));
cfg.sauceLabs = {
public: 'public'
};
// for slow browser booting, ostensibly
cfg.captureTimeout = 120000;
}
module.exports = function(config) {
var cfg = {
frameworks: [
'browserify',
'expect',
'mocha'
],
files: [
'test/browser-fixtures/bdd.js',
'test/acceptance/*.js'
],
exclude: [
'test/acceptance/http.js',
'test/acceptance/fs.js',
'test/acceptance/lookup-files.js',
'test/acceptance/require/**/*.js',
'test/acceptance/misc/**/*.js'
],
preprocessors: {
'test/**/*.js': ['browserify']
},
browserify: {
debug: true,
configure: function configure(b) {
b.ignore('glob')
.ignore('jade')
.ignore('supports-color')
.exclude('./lib-cov/mocha');
}
},
reporters: ['spec'],
colors: true,
browsers: ['PhantomJS'],
logLevel: config.LOG_INFO,
singleRun: true
};
// see https://github.com/saucelabs/karma-sauce-example
// TO RUN LOCALLY:
// Execute `CI=1 make test-browser`, once you've set the SAUCE_USERNAME and
// SAUCE_ACCESS_KEY env vars.
if (process.env.CI) {
// we can't run SauceLabs tests on PRs from forks on Travis cuz security.
if (process.env.TRAVIS) {
if (process.env.TRAVIS_REPO_SLUG === 'mochajs/mocha'
&& process.env.TRAVIS_PULL_REQUEST === 'false') {
addSauceTests(cfg);
// correlate build/tunnel with Travis
cfg.sauceLabs.build = 'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER
+ ' (' + process.env.TRAVIS_BUILD_ID + ')';
cfg.sauceLabs.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER;
cfg.sauceLabs.startConnect = true;
}
} else {
if (!(process.env.SAUCE_USERNAME || process.env.SAUCE_ACCESS_KEY)) {
throw new Error('Must set SAUCE_USERNAME and SAUCE_ACCESS_KEY '
+ 'environment variables!');
}
// remember, this is for a local run.
addSauceTests(cfg);
cfg.sauceLabs.build = require('os').hostname() + ' (' + Date.now() + ')';
}
}
// the MOCHA_UI env var will determine if we're running interface-specific
// tets. since you can only load one at a time, each must be run separately.
// each has its own set of acceptance tests and a fixture.
// the "bdd" fixture is used by default.
var ui = process.env.MOCHA_UI;
if (ui) {
if (cfg.sauceLabs) {
cfg.sauceLabs.testName = 'Interface "' + ui + '" integration tests';
}
cfg.files = [
'test/browser-fixtures/' + ui + '.js',
'test/acceptance/interfaces/' + ui + '.js'
];
} else if (cfg.sauceLabs) {
cfg.sauceLabs.testName = 'Unit Tests';
}
config.set(cfg);
};