mocha
mocha copied to clipboard
run global setup before test files load; closes #4508
BREAKING CHANGE
Mocha#run() was orchestrating if and when to run global setup/teardown fixtures, but Mocha#run() must be called after test files have been loaded. This is a problem, because:
--delaymay expect something created in a fixture to be accessible, but it won't be- Any future support for async suites is similarly negatively impacted
- It was inconsistent between "watch" and "single run" mode; "watch" mode already has this behavior!
This change causes setup fixtures to run before any test files have been loaded. In Node.js, this happens in lib/cli/run-helpers.
- Added two functions to
Mocha;Mocha#globalSetupEnabled()andMocha#globalTeardownEnabled()which both return booleans - Correct order of operations is asserted in
test/integration/global-fixtures.spec.js - Removed low-value (and newly broken) unit tests where
Mocha#runcalledrunGlobalSetup/runGlobalTeardown - Add a note to
browser-entry.jsabout global fixtures
This is breaking because:
- Browser users now must run setup/teardown fixtures manually.
- Somebody's test harness might expect test files to be loaded (and suites run) before global setup fixtures execute.
We should probably merge this, even though I'm loathe to break it--the original design will cause major headaches in future development. My bad!
Closes #4508
Coverage increased (+0.02%) to 94.138% when pulling 6bf7da79d5f9377334dfdf9ba9ea49035bbc3cd7 on boneskull/issue/4508-global-fixtures into c6856babc32b8556302a697429114d917dc70427 on master.
@boneskull Is there any chance of a merge in the near future? This issue is really a pain point for us.
@juergba Could you take a look into this? It's still a pain
What is the status of this one? It would be nice if it gets prioritized
Can you please commit this
@tj
@boneskull
So glad to see this PR being resurrected 🎉 this bug is a pain in the ass 😄
I understand that maintenance-crew need to take a look at this and approve/improve but if there is something I could help with to push this forward then I can try ;)