Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run global setup before test files load; closes #4508 #4511

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Nov 13, 2020

  1. 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:
    
    1. `--delay` may expect something created in a fixture to be accessible, but it won't be
    2. Any future support for async suites is similarly negatively impacted
    3. 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()` and `Mocha#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#run` called `runGlobalSetup`/`runGlobalTeardown`
    - Add a note to `browser-entry.js` about global fixtures
    
    This is breaking because:
    
    1. Browser users now must run setup/teardown fixtures manually.
    2. Somebody's test harness might expect test files to be loaded (and suites run) _before_ global setup fixtures execute.
    boneskull committed Nov 13, 2020
    Configuration menu
    Copy the full SHA
    6bf7da7 View commit details
    Browse the repository at this point in the history