electron/spec/static/index.html
Cheng Zhao ac31dc9672 Do not put modules used by specs on the root.
Modules in root is now installed by npm, and the native modules are now
not usable by atom-shell.
2014-04-29 11:51:49 +08:00

79 lines
1.9 KiB
HTML

<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[1] == '--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('coffee-script/register'); // Supports .coffee tests.
var ipc = require('ipc');
// Rediret all output to browser.
if (isCi) {
global.__defineGetter__('console', function() {
return {
log: function() {
args = Array.prototype.slice.call(arguments);
ipc.sendChannel('console.log', args);
},
error: function() {
args = Array.prototype.slice.call(arguments);
ipc.sendChannel('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.coffee$/.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>