Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix reporting of requires or Jest env method access after "teardown"
- Loading branch information
Showing
11 changed files
with
124 additions
and
63 deletions.
There are no files selected for viewing
20 changes: 17 additions & 3 deletions
20
e2e/__tests__/__snapshots__/environmentAfterTeardown.test.ts.snap
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 |
---|---|---|
@@ -1,13 +1,27 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`prints useful error for environment methods after test is done 1`] = ` | ||
"ReferenceError: You are trying to access a property or method of the Jest environment after it has been torn down. From __tests__/afterTeardown.test.js. | ||
"FAIL __tests__/afterTeardown.test.js | ||
✕ access environment methods after done (3 ms) | ||
● access environment methods after done | ||
ReferenceError: You are trying to access a property or method of the Jest environment outside of the scope of the test code. | ||
9 | test('access environment methods after done', () => { | ||
10 | setTimeout(() => { | ||
> 11 | jest.clearAllTimers(); | ||
| ^ | ||
12 | }, 100); | ||
12 | }, 0); | ||
13 | }); | ||
14 |" | ||
14 | | ||
at _getFakeTimers (../../packages/jest-runtime/build/index.js:1977:15) | ||
at Timeout.clearAllTimers [as _onTimeout] (__tests__/afterTeardown.test.js:11:10) | ||
Test Suites: 1 failed, 1 total | ||
Tests: 1 failed, 1 total | ||
Snapshots: 0 total | ||
Time: 0.365 s, estimated 1 s | ||
Ran all test suites." | ||
`; |
18 changes: 16 additions & 2 deletions
18
e2e/__tests__/__snapshots__/requireAfterTeardown.test.ts.snap
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 |
---|---|---|
@@ -1,13 +1,27 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`prints useful error for requires after test is done 1`] = ` | ||
"ReferenceError: You are trying to \`import\` a file after the Jest environment has been torn down. From __tests__/lateRequire.test.js. | ||
"FAIL __tests__/lateRequire.test.js | ||
✕ require after done (5 ms) | ||
● require after done | ||
ReferenceError: You are trying to \`import\` a file outside of the scope of the test code. | ||
9 | test('require after done', () => { | ||
10 | setTimeout(() => { | ||
> 11 | const double = require('../'); | ||
| ^ | ||
12 | | ||
13 | expect(double(5)).toBe(10); | ||
14 | }, 100);" | ||
14 | }, 0); | ||
at Runtime._execModule (../../packages/jest-runtime/build/index.js:1380:13) | ||
at Timeout.require [as _onTimeout] (__tests__/lateRequire.test.js:11:20) | ||
Test Suites: 1 failed, 1 total | ||
Tests: 1 failed, 1 total | ||
Snapshots: 0 total | ||
Time: 0.332 s, estimated 1 s | ||
Ran all test suites." | ||
`; |
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
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
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