Skip to content

Commit

Permalink
refactored some test fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesMessinger committed Oct 5, 2015
1 parent b3119c9 commit 2dd5d46
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 31 deletions.
1 change: 0 additions & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ function configureSauceLabs(config) {
// probably due to zero-byte files and special characters in the paths.
// So, exclude these tests when running on SauceLabs.
config.exclude = [
'tests/fixtures/config.js',
'tests/specs/__*/**',
'tests/specs/blank/**',
'tests/specs/unknown/**'
Expand Down
21 changes: 0 additions & 21 deletions tests/fixtures/config.js

This file was deleted.

12 changes: 4 additions & 8 deletions tests/fixtures/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
window.expect = chai.expect;
window.userAgent = {
isNode: false,
isBrowser: true
isBrowser: true,
isKarma: !!window.__karma__
};

// Flag known slow environments (TravisCI and SauceLabs)
global.slowEnvironment = !!window.__karma__;
}
else {
// Expose Node globals
Expand All @@ -29,11 +27,9 @@

global.userAgent = {
isNode: true,
isBrowser: false
isBrowser: false,
isTravisCI: !!process.env.TRAVIS
};

// Flag known slow environments (TravisCI and SauceLabs)
global.slowEnvironment = !!process.env.TRAVIS;
}

})();
31 changes: 31 additions & 0 deletions tests/fixtures/mocha.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Mocha configuration
(function() {
'use strict';

if (userAgent.isBrowser) {
mocha.setup('bdd');
mocha.fullTrace();
mocha.asyncOnly();
mocha.checkLeaks();
mocha.globals(['$0', '$1', '$2', '$3', '$4', '$5']);

// Output each test's name, for debugging purposes
beforeEach(function() {
console.log('START ' + this.currentTest.parent.title + ' - ' + this.currentTest.title);
});
afterEach(function() {
console.log('DONE ' + this.currentTest.parent.title + ' - ' + this.currentTest.title);
});
}

beforeEach(function() {
// Flag TravisCI and SauceLabs as being very slow environments
var isSlowEnvironment = userAgent.isTravisCI || userAgent.isKarma;

// Most of our tests perform multiple AJAX requests,
// so we need to increase the timeouts to allow for that
this.currentTest.timeout(isSlowEnvironment ? 10000 : 3000);
this.currentTest.slow(500);
});

})();
2 changes: 1 addition & 1 deletion tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
<script src="../dist/ref-parser.js"></script>

<!-- Test Fixtures -->
<script src="fixtures/config.js"></script>
<script src="fixtures/globals.js"></script>
<script src="fixtures/helper.js"></script>
<script src="fixtures/mocha.js"></script>
<script src="fixtures/path.js"></script>

<!-- Tests -->
Expand Down

0 comments on commit 2dd5d46

Please sign in to comment.