-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Prerequisites
- Checked that your issue hasn't already been filed by cross-referencing issues with the
faq
label - Checked next-gen ES issues and syntax problems by using the same environment and/or transpiler configuration without Mocha to ensure it isn't just a feature that actually isn't supported in the environment in question or a bug in your code.
- 'Smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, your usage of Mocha, or Mocha itself
- Ensured that there is no discrepancy between the locally and globally installed versions of Mocha. You can find them with:
node node_modules/.bin/mocha --version
(Local) andmocha --version
(Global). We recommend that you not install Mocha globally.
Description
A hook's title is only rewritten to include the test's name when it fails. This means the name is inconsistent between hook start and hook failure, which is messing up the logging of a custom reporter. Additionally, the hook name is incomplete when it starts, because it does not include the name of the associated test.
Rewriting is done here: https://github.com/mochajs/mocha/blob/master/lib/runner.js#L419-L432
'hook' event: title = "before each" hook
'fail' event: title = "before each" hook for "name of test case"
, originalTitle = "before each" hook
Steps to Reproduce
Run this reproduction: https://github.com/cspotcode/repros/tree/mocha-hook-title-discrepancy
Expected behavior: [What you expect to happen]
Hook's title
includes the from "name of test case"
for all events.
Actual behavior: [What actually happens]
Hook title does not include from "name of test case"
suffix in 'hook' event and never includes if it succeeds.
Reproduces how often: [What percentage of the time does it reproduce?]
all the time
Versions
mocha --version
: N/A, not installednode node_modules/.bin/mocha --version
: 8.0.1- The output of
node --version
: v14.2.0 - Your operating system
- name and version: Windows 10, WSL2, running Ubuntu 16.04.6 LTS
- architecture (32 or 64-bit): 64bit
- Your shell (e.g., bash, zsh, PowerShell, cmd): bash
- Your browser and version (if running browser tests): N/A
- Any third-party Mocha-related modules (and their versions): custom reporter which listens to
hook
,hook end
, andfail
events - Any code transpiler (e.g., TypeScript, CoffeeScript, Babel) being used (and its version): none