forked from emberjs/ember-qunit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-loader.js
61 lines (49 loc) · 1.43 KB
/
test-loader.js
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
import * as QUnit from 'qunit';
import AbstractTestLoader, {
addModuleExcludeMatcher,
addModuleIncludeMatcher,
} from 'ember-cli-test-loader/test-support/index';
addModuleExcludeMatcher(function (moduleName) {
return QUnit.urlParams.nolint && moduleName.match(/\.(jshint|lint-test)$/);
});
addModuleIncludeMatcher(function (moduleName) {
return moduleName.match(/\.jshint$/);
});
let moduleLoadFailures = [];
QUnit.done(function () {
let length = moduleLoadFailures.length;
try {
if (length === 0) {
// do nothing
} else if (length === 1) {
throw moduleLoadFailures[0];
} else {
throw new Error('\n' + moduleLoadFailures.join('\n'));
}
} finally {
// ensure we release previously captured errors.
moduleLoadFailures = [];
}
});
export class TestLoader extends AbstractTestLoader {
moduleLoadFailure(moduleName, error) {
moduleLoadFailures.push(error);
QUnit.module('TestLoader Failures');
QUnit.test(moduleName + ': could not be loaded', function () {
throw error;
});
}
}
/**
Load tests following the default patterns:
* The module name ends with `-test`
* The module name ends with `.jshint`
Excludes tests that match the following
patterns when `?nolint` URL param is set:
* The module name ends with `.jshint`
* The module name ends with `-lint-test`
@method loadTests
*/
export function loadTests() {
new TestLoader().loadModules();
}