Last active
August 13, 2019 18:33
-
-
Save BretCameron/64796d7fb1f9b2e1d38ed5a977ce52d2 to your computer and use it in GitHub Desktop.
Using Mocha in Node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const Mocha = require('mocha'); | |
| const test = new Mocha(); | |
| test.addFile('./assert.js'); | |
| let runner = test.run(); | |
| const passed = []; | |
| const failed = []; | |
| runner.on('pass', (e) => { | |
| passed.push({ | |
| title: e.title, | |
| speed: e.speed, | |
| duration: e.duration, | |
| file: e.file | |
| }); | |
| console.log(passed); | |
| }); | |
| runner.on('fail', (e) => { | |
| failed.push({ | |
| title: e.title, | |
| err: error, | |
| file: e.file | |
| }); | |
| console.log(failed); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
const Mocha = require('mocha');
const test = new Mocha();
test.addFile('./assert.js');
let runner = test.run();
runner.on('pass', (e) => {
passed.push({
title: e.title,
speed: e.speed,
duration: e.duration,
file: e.file
});
});
runner.on('fail', (e) => {
failed.push({
title: e.title,
err: error,
file: e.file
});
});