-
-
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.
More, improved integration tests for watching (#3929)
To extend the test coverage for mocha in watch mode we add the following two tests: * Check that test files are reloaded * Check that watched dependencies are reloaded To support this change we consolidate `runMochaJSONWatchAsync`, `runMochaJSONRawAsync`, and repeated code in tests into `runMochaWatch`. We introduce `invokeMochaAsync` in `test/integration/helpers` as an async alternative to `invokeMocha`. We also eliminate the test for the cursor control character in the output. Its usefulness is dubious as it relies on an implementation detail and the other tests cover the intended behavior. We are also more explicit which test fixtures are used. Instead of setting `this.testFile` in a `beforeEach` hook we do this explicitly for the tests that require it. This prevents interference in tests that do not use the file.
- Loading branch information
Showing
5 changed files
with
168 additions
and
139 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports.testShouldFail = false; |
8 changes: 8 additions & 0 deletions
8
test/integration/fixtures/options/watch/test-file-change.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,8 @@ | ||
// This will be replaced in the tests | ||
const testShouldFail = true; | ||
|
||
it('checks dependency', () => { | ||
if (testShouldFail === true) { | ||
throw new Error('test failed'); | ||
} | ||
}); |
7 changes: 7 additions & 0 deletions
7
test/integration/fixtures/options/watch/test-with-dependency.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,7 @@ | ||
const dependency = require('./lib/dependency'); | ||
|
||
it('checks dependency', () => { | ||
if (dependency.testShouldFail === true) { | ||
throw new Error('test failed'); | ||
} | ||
}); |
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