Hook only renamed when it fails, not when it begins and ends successfully #4348
Labels
status: accepting prs
Mocha can use your help with this one!
type: bug
a defect, confirmed by a maintainer
Prerequisites
faq
labelnode 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 thefrom "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.1node --version
: v14.2.0hook
,hook end
, andfail
eventsAdditional Information
The text was updated successfully, but these errors were encountered: