sets the current mocha test name to a global variable (yeah, it's useful sometimes!)
Last updated 5 years ago by refractalize .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install mocha-test-name 
SYNC missed versions from official npm registry.

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:


In your app:

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

Current Tags

  • 1.0.0                                ...           latest (5 years ago)

1 Versions

  • 1.0.0                                ...           5 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
Dev Dependencies (0)
Dependents (0)

Copyright 2014 - 2016 © |