2018-02-21 05:31:27 +01:00
|
|
|
const html = require('choo/html');
|
|
|
|
const assets = require('../../common/assets');
|
2018-11-20 21:07:47 +01:00
|
|
|
const initScript = require('../../server/initScript');
|
2018-02-21 05:31:27 +01:00
|
|
|
|
|
|
|
module.exports = function(app) {
|
|
|
|
app.get('/mocha.css', function(req, res) {
|
|
|
|
res.sendFile(require.resolve('mocha/mocha.css'));
|
|
|
|
});
|
|
|
|
app.get('/mocha.js', function(req, res) {
|
|
|
|
res.sendFile(require.resolve('mocha/mocha.js'));
|
|
|
|
});
|
|
|
|
app.get('/test', function(req, res) {
|
|
|
|
res.send(
|
|
|
|
html`
|
2018-11-16 21:39:36 +01:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/mocha.css" />
|
|
|
|
<script src="/mocha.js"></script>
|
|
|
|
<script>
|
|
|
|
const reporters = mocha.constructor.reporters;
|
|
|
|
function Combo(runner) {
|
|
|
|
reporters.HTML.call(this, runner);
|
|
|
|
reporters.JSON.call(this, runner);
|
|
|
|
}
|
|
|
|
Object.setPrototypeOf(Combo.prototype, reporters.HTML.prototype);
|
|
|
|
mocha.setup({
|
|
|
|
ui: 'bdd',
|
|
|
|
reporter: Combo,
|
|
|
|
timeout: 5000
|
|
|
|
});
|
|
|
|
</script>
|
2019-01-24 21:31:20 +01:00
|
|
|
${initScript({
|
|
|
|
cspNonce: 'test',
|
|
|
|
locale: 'en-US'
|
|
|
|
})}
|
2018-11-16 21:39:36 +01:00
|
|
|
<script src="${assets.get('tests.js')}"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="mocha"></div>
|
|
|
|
<script>
|
|
|
|
window.runner = mocha.run();
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|
2018-02-21 05:31:27 +01:00
|
|
|
`.toString()
|
|
|
|
);
|
|
|
|
});
|
|
|
|
};
|