You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You may also pick any file and add “root”-level hooks. For example, add beforeEach() outside of all describe() blocks. This will cause the callback to beforeEach() to run before any test case, regardless of the file it lives in (this is because Mocha has an implied describe() block, called the “root suite”).
... This is typically done in Node by placing your hook(s) in a .js module, and using the --require /path/to/module option on the command-line.
However, if I attempt to load a "hook" file with --require, I get an error like:
$ mocha --require /path/to/hook/file.js
ReferenceError: before is not defined
at Object.<anonymous> (/path/to/hook/file.js:1:1)
The text was updated successfully, but these errors were encountered:
This is typically done in Node by placing your hook(s) in a .js module, and including it in your test run.
For example:
mocha --recursive /path/to/hook/file test/spec
According to the docs:
However, if I attempt to load a "hook" file with
--require
, I get an error like:The text was updated successfully, but these errors were encountered: