-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
7 changed files
with
105 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
test/integration/fixtures/plugins/global-fixtures/global.fixture.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict'; | ||
|
||
console.log('test fixture loaded'); | ||
|
||
describe('a suite', function() { | ||
it('should succeed', function(done) { | ||
done(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.