Skip to content

Commit 2dd5d46

Browse files
refactored some test fixtures
1 parent b3119c9 commit 2dd5d46

File tree

5 files changed

+36
-31
lines changed

5 files changed

+36
-31
lines changed

karma.conf.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ function configureSauceLabs(config) {
172172
// probably due to zero-byte files and special characters in the paths.
173173
// So, exclude these tests when running on SauceLabs.
174174
config.exclude = [
175-
'tests/fixtures/config.js',
176175
'tests/specs/__*/**',
177176
'tests/specs/blank/**',
178177
'tests/specs/unknown/**'

tests/fixtures/config.js

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

tests/fixtures/globals.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@
1515
window.expect = chai.expect;
1616
window.userAgent = {
1717
isNode: false,
18-
isBrowser: true
18+
isBrowser: true,
19+
isKarma: !!window.__karma__
1920
};
20-
21-
// Flag known slow environments (TravisCI and SauceLabs)
22-
global.slowEnvironment = !!window.__karma__;
2321
}
2422
else {
2523
// Expose Node globals
@@ -29,11 +27,9 @@
2927

3028
global.userAgent = {
3129
isNode: true,
32-
isBrowser: false
30+
isBrowser: false,
31+
isTravisCI: !!process.env.TRAVIS
3332
};
34-
35-
// Flag known slow environments (TravisCI and SauceLabs)
36-
global.slowEnvironment = !!process.env.TRAVIS;
3733
}
3834

3935
})();

tests/fixtures/mocha.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Mocha configuration
2+
(function() {
3+
'use strict';
4+
5+
if (userAgent.isBrowser) {
6+
mocha.setup('bdd');
7+
mocha.fullTrace();
8+
mocha.asyncOnly();
9+
mocha.checkLeaks();
10+
mocha.globals(['$0', '$1', '$2', '$3', '$4', '$5']);
11+
12+
// Output each test's name, for debugging purposes
13+
beforeEach(function() {
14+
console.log('START ' + this.currentTest.parent.title + ' - ' + this.currentTest.title);
15+
});
16+
afterEach(function() {
17+
console.log('DONE ' + this.currentTest.parent.title + ' - ' + this.currentTest.title);
18+
});
19+
}
20+
21+
beforeEach(function() {
22+
// Flag TravisCI and SauceLabs as being very slow environments
23+
var isSlowEnvironment = userAgent.isTravisCI || userAgent.isKarma;
24+
25+
// Most of our tests perform multiple AJAX requests,
26+
// so we need to increase the timeouts to allow for that
27+
this.currentTest.timeout(isSlowEnvironment ? 10000 : 3000);
28+
this.currentTest.slow(500);
29+
});
30+
31+
})();

tests/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
<script src="../dist/ref-parser.js"></script>
2222

2323
<!-- Test Fixtures -->
24-
<script src="fixtures/config.js"></script>
2524
<script src="fixtures/globals.js"></script>
2625
<script src="fixtures/helper.js"></script>
26+
<script src="fixtures/mocha.js"></script>
2727
<script src="fixtures/path.js"></script>
2828

2929
<!-- Tests -->

0 commit comments

Comments
 (0)