Skip to content

Instantly share code, notes, and snippets.

@BretCameron
Last active August 13, 2019 18:33
Show Gist options
  • Select an option

  • Save BretCameron/64796d7fb1f9b2e1d38ed5a977ce52d2 to your computer and use it in GitHub Desktop.

Select an option

Save BretCameron/64796d7fb1f9b2e1d38ed5a977ce52d2 to your computer and use it in GitHub Desktop.
Using Mocha in Node.js
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);
});
@hafridi
Copy link

hafridi commented Aug 13, 2019

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
});
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment