electron/spec/static/index.html

103 lines
2.6 KiB
HTML
Raw Normal View History

2013-07-17 08:28:14 +00:00
<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>
2013-07-17 08:28:14 +00:00
</head>
<body>
<div id="mocha"></div>
<script type="text/javascript" charset="utf-8">
(function() {
// Disable use of deprecated functions.
process.throwDeprecation = true;
var path = require('path');
var electron = require ('electron');
var remote = electron.remote;
var ipcRenderer = electron.ipcRenderer;
// Check if we are running in CI.
var isCi = remote.getGlobal('isCi')
2013-08-21 03:35:39 +00:00
if (!isCi) {
var win = remote.getCurrentWindow();
2013-08-21 03:35:39 +00:00
win.show();
win.focus();
}
// Show DevTools.
document.oncontextmenu = function(e) {
remote.getCurrentWindow().inspectElement(e.clientX, e.clientY);
}
// Rediret all output to browser.
if (isCi) {
global.__defineGetter__('console', function() {
return {
log: function() {
args = Array.prototype.slice.call(arguments);
ipcRenderer.send('console.log', args);
},
error: function() {
args = Array.prototype.slice.call(arguments);
ipcRenderer.send('console.error', args);
},
}
});
}
var Coverage = require('electabul').Coverage;
2013-07-17 08:28:14 +00:00
var Mocha = require('mocha');
var mocha = new Mocha();
2013-08-21 03:35:39 +00:00
mocha.ui('bdd').reporter(isCi ? 'tap' : 'html');
2013-07-17 08:28:14 +00:00
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
});
2013-07-17 08:28:14 +00:00
walker.on('file', function(file) {
2016-01-12 01:01:14 +00:00
if (/-spec\.js$/.test(file))
2013-07-17 08:28:14 +00:00
mocha.addFile(file);
});
walker.on('end', function() {
var runner = mocha.run(function() {
if (isCi && runner.hasOnly) {
try {
throw new Error('A spec contains a call to it.only or describe.only and should be reverted.')
} catch (error) {
console.error(error.stack || error)
}
ipcRenderer.send('process.exit', 1)
return
}
2013-07-17 08:28:14 +00:00
Mocha.utils.highlightTags('code');
var coverage = new Coverage({
libPath: path.join(__dirname, '..', '..', 'lib'),
outputPath: path.join(__dirname, '..', '..', 'out', 'coverage'),
formats: ['text', 'lcov']
});
coverage.addCoverage(ipcRenderer.sendSync('get-main-process-coverage'))
coverage.generateReport()
if (isCi)
ipcRenderer.send('process.exit', runner.failures);
2013-07-17 08:28:14 +00:00
});
});
})();
</script>
</body>
</html>