/
run-all.js.tmpl
49 lines (43 loc) · 1.17 KB
/
run-all.js.tmpl
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
(function() {
"use strict";
var nodeunit = require("nodeunit");
var callChrome = window.callChrome;
var tests;
/**
* Nodeunit's "browser" reporter expects Nodeunit to be available on the
* global scope. Expose it in all cases to promote consistency between the
* Chrome and "true" browser execution contexts.
*/
window.nodeunit = nodeunit;
tests = {
{{ INJECT_TEST_INCLUDES }}
};
function runHeadless() {
/**
* Source:
* https://github.com/caolan/nodeunit/blob/60b7d67250a8005fcca6d71a18697c9bdc6613bd/bin/nodeunit.json
*/
var colors = {
error_prefix: "\u001B[31m",
error_suffix: "\u001B[39m",
ok_prefix: "\u001B[32m",
ok_suffix: "\u001B[39m",
bold_prefix: "\u001B[1m",
bold_suffix: "\u001B[22m",
assertion_prefix: "\u001B[35m",
assertion_suffix: "\u001B[39m"
};
nodeunit.reporters.default.run(tests, colors, function(err) {
callChrome();
});
}
function runHeadful() {
var reporter = require("nodeunit/lib/reporters/browser");
reporter.run(tests);
}
if (/Chrome/.test(navigator.userAgent)) {
runHeadless();
} else {
runHeadful();
}
}());