vendredi 6 février 2015

Global hooks when running specific file

I have test/app/global-hooks.js, with a couple of hooks.


When I pass mocha the folder, to run all the test files (mocha test/app) the hooks run just fine. But when I want to run a single test file: mocha test/app/foo.js, the hooks will simply not run.


Requiring also doesn't work: mocha -r test/app/global-hooks.js test/app/foo.js. This results in an error:



beforeEach(function(done) {
^
ReferenceError: beforeEach is not defined


How can I have common hooks in a separate file, and be able to run test files individually ?


Aucun commentaire:

Enregistrer un commentaire