-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
177 additions
and
5 deletions.
There are no files selected for viewing
14 changes: 13 additions & 1 deletion
14
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
25 changes: 25 additions & 0 deletions
25
e2e/__tests__/__snapshots__/environmentAfterTeardownJasmine.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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// 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. | ||
9 | test('access environment methods after done', () => { | ||
10 | setTimeout(() => { | ||
> 11 | jest.clearAllTimers(); | ||
| ^ | ||
12 | }, 0); | ||
13 | }); | ||
14 |" | ||
`; | ||
|
||
exports[`prints useful error for environment methods after test is done 2`] = ` | ||
"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. | ||
9 | test('access environment methods after done', () => { | ||
10 | setTimeout(() => { | ||
> 11 | jest.clearAllTimers(); | ||
| ^ | ||
12 | }, 0); | ||
13 | }); | ||
14 |" | ||
`; |
14 changes: 13 additions & 1 deletion
14
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
25 changes: 25 additions & 0 deletions
25
e2e/__tests__/__snapshots__/requireAfterTeardownJasmine.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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// 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. | ||
9 | test('require after done', () => { | ||
10 | setTimeout(() => { | ||
> 11 | const double = require('../'); | ||
| ^ | ||
12 | | ||
13 | expect(double(5)).toBe(10); | ||
14 | }, 0);" | ||
`; | ||
exports[`prints useful error for requires after test is done 2`] = ` | ||
"ReferenceError: You are trying to \`import\` a file after the Jest environment has been torn down. From __tests__/lateRequire.test.js. | ||
9 | test('require after done', () => { | ||
10 | setTimeout(() => { | ||
> 11 | const double = require('../'); | ||
| ^ | ||
12 | | ||
13 | expect(double(5)).toBe(10); | ||
14 | }, 0);" | ||
`; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import {skipSuiteOnJestCircus} from '@jest/test-utils'; | ||
import runJest from '../runJest'; | ||
|
||
skipSuiteOnJestCircus(); | ||
|
||
test.each` | ||
jestArgs | ||
${[]} | ||
${['--waitNextEventLoopTurnForUnhandledRejectionEvents']} | ||
`( | ||
'prints useful error for environment methods after test is done', | ||
({jestArgs}) => { | ||
const {stderr} = runJest('environment-after-teardown', jestArgs); | ||
const interestingLines = stderr.split('\n').slice(9, 18).join('\n'); | ||
|
||
expect(interestingLines).toMatchSnapshot(); | ||
expect(stderr.split('\n')[9]).toBe( | ||
'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.', | ||
); | ||
}, | ||
); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import {skipSuiteOnJestCircus} from '@jest/test-utils'; | ||
import runJest from '../runJest'; | ||
|
||
skipSuiteOnJestCircus(); | ||
|
||
test.each` | ||
jestArgs | ||
${[]} | ||
${['--waitNextEventLoopTurnForUnhandledRejectionEvents']} | ||
`('prints useful error for requires after test is done', ({jestArgs}) => { | ||
const {stderr} = runJest('require-after-teardown', jestArgs); | ||
|
||
const interestingLines = stderr.split('\n').slice(9, 18).join('\n'); | ||
|
||
expect(interestingLines).toMatchSnapshot(); | ||
expect(stderr.split('\n')[19]).toMatch( | ||
'(__tests__/lateRequire.test.js:11:20)', | ||
); | ||
}); |