/
index.html
81 lines (67 loc) 路 1.89 KB
/
index.html
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<html>
<head>
<meta name="referrer" content="always">
<link href="../node_modules/mocha/mocha.css" rel="stylesheet">
<script src="jquery-2.0.3.min.js"></script>
</head>
<body>
<div id="mocha"></div>
<script type="text/javascript" charset="utf-8">
(function() {
// Disable use of deprecated functions.
process.throwDeprecation = true;
// Check if we are running in CI.
var argv = require('remote').process.argv;
var isCi = argv[2] == '--ci';
if (!isCi) {
var win = require('remote').getCurrentWindow();
win.show();
win.focus();
}
// Show DevTools.
document.oncontextmenu = function(e) {
require('remote').getCurrentWindow().inspectElement(e.clientX, e.clientY);
}
require('babel/register'); // Supports .es6 tests
var ipc = require('ipc');
// Redirect all output to nodejs.
if (isCi) {
global.__defineGetter__('console', function() {
return {
log: function() {
args = Array.prototype.slice.call(arguments);
ipc.send('console.log', args);
},
error: function() {
args = Array.prototype.slice.call(arguments);
ipc.send('console.error', args);
},
}
});
}
var Mocha = require('mocha');
var mocha = new Mocha();
mocha.ui('bdd').reporter(isCi ? 'tap' : 'html');
var query = Mocha.utils.parseQuery(window.location.search || '');
if (query.grep) mocha.grep(query.grep);
if (query.invert) mocha.invert();
// Read all test files.
var walker = require('walkdir').walk(require('path').dirname(__dirname), {
no_recurse: true
});
walker.on('file', function(file) {
if (/-spec.js/.test(file))
mocha.addFile(file);
});
walker.on('end', function() {
var runner = mocha.run(function() {
Mocha.utils.highlightTags('code');
if (isCi) {
ipc.send('process.exit', runner.failures);
}
});
});
})();
</script>
</body>
</html>