Skip to content

fix: apply require root hooks in programmatic serial runs - #6232

Open
arronKler wants to merge 1 commit into
mochajs:mainfrom
arronKler:fix/5006-root-hooks-serial
Open

fix: apply require root hooks in programmatic serial runs#6232
arronKler wants to merge 1 commit into
mochajs:mainfrom
arronKler:fix/5006-root-hooks-serial

Conversation

@arronKler

Copy link
Copy Markdown

PR Checklist

Overview

--require files that export mochaHooks already run under the CLI and in parallel workers, because both call handleRequires before constructing Mocha. A programmatic serial run (new Mocha({ require })) never did that, so the root hooks were skipped.

Mocha#run now loads those plugins when rootHooks was not already supplied. handleRequires lives in lib/nodejs so the Mocha class does not import CLI helpers.

Fixes #5006

CLI and worker startup already load mochaHooks from --require.
Programmatic serial runs did not, so those root hooks never ran.

Fixes mochajs#5006
@linux-foundation-easycla

Copy link
Copy Markdown

CLA Not Signed

@arronKler

Copy link
Copy Markdown
Author

recheck

@mark-wiemer mark-wiemer added this to Mocha Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

🐛 Bug: Root hooks not executed when programmatically running Mocha in serial mode

2 participants