some frontend unit tests
This commit is contained in:
parent
4929437283
commit
78728ce4ca
24 changed files with 708 additions and 417 deletions
47
test/frontend/routes.js
Normal file
47
test/frontend/routes.js
Normal file
|
@ -0,0 +1,47 @@
|
|||
const html = require('choo/html');
|
||||
const assets = require('../../common/assets');
|
||||
|
||||
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`
|
||||
<!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
|
||||
})
|
||||
</script>
|
||||
<script src="/jsconfig.js"></script>
|
||||
<script src="${assets.get('runtime.js')}"></script>
|
||||
<script src="${assets.get('vendor.js')}"></script>
|
||||
<script src="${assets.get('tests.js')}"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
<script>
|
||||
mocha.checkLeaks();
|
||||
const runner = mocha.run();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
`.toString()
|
||||
);
|
||||
});
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue