Skip to content

Commit

Permalink
Travis + SauceLabs + Karma setup (second pass)
Browse files Browse the repository at this point in the history
- 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`
  • Loading branch information
boneskull committed May 22, 2016
1 parent c962a51 commit e20a003
Show file tree
Hide file tree
Showing 14 changed files with 4,729 additions and 4,459 deletions.
4 changes: 0 additions & 4 deletions .karma-config/fixture.js

This file was deleted.

74 changes: 0 additions & 74 deletions .karma-config/index.js

This file was deleted.

8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ test: lint test-node test-browser

test-browser-unit: mocha.js
@printf "==> [Test :: Browser]\n"
@$(KARMA) start
@NODE_PATH=. $(KARMA) start

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

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

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

test-jsapi:
@printf "==> [Test :: JS API]\n"
Expand Down
3 changes: 3 additions & 0 deletions browser-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,7 @@ Mocha.process = process;
global.Mocha = Mocha;
global.mocha = mocha;

// this allows test/acceptance/required-tokens.js to pass; thus,
// you can now do `const describe = require('mocha').describe` in a
// browser context (assuming browserification). should fix #880
module.exports = global;
93 changes: 88 additions & 5 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,96 @@
var getConfig = require('./.karma-config');
'use strict';

module.exports = function(config) {
var cfg = getConfig();
var ui = process.env.KARMA_INTERFACE;
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) {
if (!(process.env.SAUCE_USERNAME || process.env.SAUCE_ACCESS_KEY)) {
throw new Error('Must set SAUCE_USERNAME and SAUCE_ACCESS_KEY '
+ 'environment variables!');
}
cfg.reporters.push('saucelabs');
cfg.browsers.push('ie8');
cfg.customLaunchers = {
ie8: {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows XP',
version: '8.0'
}
};

cfg.sauceLabs = {
public: 'public'
};

if (process.env.TRAVIS) {
// 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 = false;
} else {
// otherwise just make something up
cfg.sauceLabs.build = require('os').hostname() + ' (' + Date.now() + ')';
}

// for slow browser booting, ostensibly
cfg.captureTimeout = 120000;
}

// 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 = [
getConfig.uiFixturePaths[ui],
'./test/acceptance/interfaces/' + ui + '.js'
'test/browser-fixtures/' + ui + '.js',
'test/acceptance/interfaces/' + ui + '.js'
];
} else if (cfg.sauceLabs) {
cfg.sauceLabs.testName = 'Unit Tests';
}

config.set(cfg);
Expand Down
2 changes: 1 addition & 1 deletion lib/browser/tty.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
exports.isatty = function isatty() {
return false;
return true;
};

exports.getWindowSize = function getWindowSize() {
Expand Down

0 comments on commit e20a003

Please sign in to comment.