Skip to content

Commit dd68d84

Browse files
committed
Travis + SauceLabs + Karma setup (second pass)
- add note about exporting `global` in `browser-entry.js` - remove too-short timeout for "throw" unit tests (because SauceLabs) - revert modification to `isatty()` function of `lib/browser/tty.js` - switch reporter to `karma-spec-reporter` - use custom `karma-no-mocha` package - fixtures in `test/browser-fixtures/` - use single `karma.conf.js`
1 parent c962a51 commit dd68d84

File tree

14 files changed

+4731
-4458
lines changed

14 files changed

+4731
-4458
lines changed

.karma-config/fixture.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

.karma-config/index.js

Lines changed: 0 additions & 74 deletions
This file was deleted.

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ test-browser-unit: mocha.js
5252

5353
test-browser-bdd:
5454
@printf "==> [Test :: Browser :: BDD]\n"
55-
@KARMA_INTERFACE=bdd $(MAKE) test-browser-unit
55+
@MOCHA_UI=bdd $(MAKE) test-browser-unit
5656

5757
test-browser-qunit:
5858
@printf "==> [Test :: Browser :: QUnit]\n"
59-
@KARMA_INTERFACE=qunit $(MAKE) test-browser-unit
59+
@MOCHA_UI=qunit $(MAKE) test-browser-unit
6060

6161
test-browser-tdd:
6262
@printf "==> [Test :: Browser :: TDD]\n"
63-
@KARMA_INTERFACE=tdd $(MAKE) test-browser-unit
63+
@MOCHA_UI=tdd $(MAKE) test-browser-unit
6464

6565
test-jsapi:
6666
@printf "==> [Test :: JS API]\n"

browser-entry.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,7 @@ Mocha.process = process;
160160
global.Mocha = Mocha;
161161
global.mocha = mocha;
162162

163+
// this allows test/acceptance/required-tokens.js to pass; thus,
164+
// you can now do `const describe = require('mocha').describe` in a
165+
// browser context (assuming browserification). should fix #880
163166
module.exports = global;

karma.conf.js

Lines changed: 91 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,99 @@
1-
var getConfig = require('./.karma-config');
1+
'use strict';
22

33
module.exports = function(config) {
4-
var cfg = getConfig();
5-
var ui = process.env.KARMA_INTERFACE;
4+
var cfg = {
5+
frameworks: [
6+
'browserify',
7+
'expect',
8+
'mocha'
9+
],
10+
files: [
11+
'test/browser-fixtures/bdd.js',
12+
'test/acceptance/*.js'
13+
],
14+
karmaMocha: {
15+
mochaDir: __dirname
16+
},
17+
exclude: [
18+
'test/acceptance/http.js',
19+
'test/acceptance/fs.js',
20+
'test/acceptance/lookup-files.js',
21+
'test/acceptance/require/**/*.js',
22+
'test/acceptance/misc/**/*.js'
23+
],
24+
preprocessors: {
25+
'test/**/*.js': ['browserify']
26+
},
27+
browserify: {
28+
debug: true,
29+
configure: function configure(b) {
30+
b.ignore('glob')
31+
.ignore('jade')
32+
.ignore('supports-color')
33+
.exclude('./lib-cov/mocha');
34+
}
35+
},
36+
reporters: ['spec'],
37+
colors: true,
38+
browsers: ['PhantomJS'],
39+
logLevel: config.LOG_INFO,
40+
singleRun: true
41+
};
42+
43+
// see https://github.com/saucelabs/karma-sauce-example
44+
// TO RUN LOCALLY:
45+
// Execute `CI=1 make test-browser`, once you've set the SAUCE_USERNAME and
46+
// SAUCE_ACCESS_KEY env vars.
47+
if (process.env.CI) {
48+
if (!(process.env.SAUCE_USERNAME || process.env.SAUCE_ACCESS_KEY)) {
49+
throw new Error('Must set SAUCE_USERNAME and SAUCE_ACCESS_KEY '
50+
+ 'environment variables!');
51+
}
52+
cfg.reporters.push('saucelabs');
53+
cfg.browsers.push('ie8');
54+
cfg.customLaunchers = {
55+
ie8: {
56+
base: 'SauceLabs',
57+
browserName: 'internet explorer',
58+
platform: 'Windows XP',
59+
version: '8.0'
60+
}
61+
};
62+
63+
cfg.sauceLabs = {
64+
public: 'public'
65+
};
66+
67+
if (process.env.TRAVIS) {
68+
// correlate build/tunnel with Travis
69+
cfg.sauceLabs.build = 'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER
70+
+ ' (' + process.env.TRAVIS_BUILD_ID + ')';
71+
cfg.sauceLabs.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER;
72+
cfg.sauceLabs.startConnect = false;
73+
} else {
74+
// otherwise just make something up
75+
cfg.sauceLabs.build = require('os').hostname() + ' (' + Date.now() + ')';
76+
}
77+
78+
// for slow browser booting, ostensibly
79+
cfg.captureTimeout = 120000;
80+
}
81+
82+
// the MOCHA_UI env var will determine if we're running interface-specific
83+
// tets. since you can only load one at a time, each must be run separately.
84+
// each has its own set of acceptance tests and a fixture.
85+
// the "bdd" fixture is used by default.
86+
var ui = process.env.MOCHA_UI;
687
if (ui) {
88+
if (cfg.sauceLabs) {
89+
cfg.sauceLabs.testName = 'Interface "' + ui + '" integration tests';
90+
}
791
cfg.files = [
8-
getConfig.uiFixturePaths[ui],
9-
'./test/acceptance/interfaces/' + ui + '.js'
92+
'test/browser-fixtures/' + ui + '.js',
93+
'test/acceptance/interfaces/' + ui + '.js'
1094
];
95+
} else if (cfg.sauceLabs) {
96+
cfg.sauceLabs.testName = 'Unit Tests';
1197
}
1298

1399
config.set(cfg);

lib/browser/tty.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
exports.isatty = function isatty() {
2-
return false;
2+
return true;
33
};
44

55
exports.getWindowSize = function getWindowSize() {

0 commit comments

Comments
 (0)