electron/spec/index.html
Cheng Zhao d56a7d75de Use jQuery instead of zepto.
zepto always fails when requesting custom protocols, 💩.
2013-08-25 16:23:40 +08:00

71 lines
1.7 KiB
HTML

<html>
<head>
<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() {
// 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'); // Supports .coffee tests.
// Rediret all output to browser.
var ipc = require('ipc');
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(__dirname);
walker.on('file', function(file) {
if (/.coffee$/.test(file))
mocha.addFile(file);
});
walker.on('end', function() {
var runner = mocha.run(function() {
Mocha.utils.highlightTags('code');
if (isCi)
ipc.sendChannel('process.exit', runner.failures);
});
});
})();
</script>
</body>
</html>