mocha-test-name

1.0.0 • Public • Published

Write the current mocha test name to a global variable

This sounds rediculous, but there really are times when this is useful, hear me out.

Sometimes, when you're testing a web app using browser-monkey, some part of your app makes an asynchronous call that ends and throws an error after the end of the test, sometimes during the next test or test after that. This is notoriously difficult to debug because you don't know which test actually caused the error. This simple module notes the name of the test as it's running, so you can use it in your error messages and find out which test caused the failure.

npm install mocha-test-name

In your test suite:

require('mocha-test-name');

In your app:

var testName = window.mochaTestName;
return somethingAsynchronous().then(undefined, function (error) {
  error.message = testName + '' + error.message;
  throw error;
});

Readme

Keywords

Package Sidebar

Install

npm i mocha-test-name

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • refractalize