Skip to content

featurist/mocha-test-name

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

sets the current mocha test name to a global variable (because global variables are awesome)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published