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

Revert "Prevent false test failures caused by promise rejections handled asynchronously (#14110)" #14304

Merged
merged 3 commits into from Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,8 @@

### Fixes

- `[jest-circus]` Revert [#14110](https://github.com/jestjs/jest/pull/14110) as it was a breaking change

### Chore & Maintenance

### Performance
Expand Down
@@ -1,7 +1,7 @@
// 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 outside of the scope of the test code.
"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(() => {
Expand Down

This file was deleted.

236 changes: 0 additions & 236 deletions e2e/__tests__/__snapshots__/promiseAsyncHandling.test.ts.snap

This file was deleted.

@@ -1,7 +1,7 @@
// 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 outside of the scope of the test code.
"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(() => {
Expand Down

This file was deleted.

9 changes: 3 additions & 6 deletions e2e/__tests__/environmentAfterTeardown.test.ts
Expand Up @@ -5,17 +5,14 @@
* LICENSE file in the root directory of this source tree.
*/

import {skipSuiteOnJasmine} from '@jest/test-utils';
import runJest from '../runJest';

skipSuiteOnJasmine();

test('prints useful error for environment methods after test is done', () => {
const {stderr} = runJest('environment-after-teardown');
const interestingLines = stderr.split('\n').slice(5, 14).join('\n');
const interestingLines = stderr.split('\n').slice(9, 18).join('\n');

expect(interestingLines).toMatchSnapshot();
expect(stderr.split('\n')[5]).toMatch(
'ReferenceError: You are trying to access a property or method of the Jest environment outside of the scope of the test code.',
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.',
);
});
21 changes: 0 additions & 21 deletions e2e/__tests__/environmentAfterTeardownJasmine.test.ts

This file was deleted.

6 changes: 1 addition & 5 deletions e2e/__tests__/fakeTimersLegacy.test.ts
Expand Up @@ -5,7 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

import {isJestJasmineRun} from '@jest/test-utils';
import runJest from '../runJest';

describe('enableGlobally', () => {
Expand Down Expand Up @@ -40,13 +39,10 @@ describe('requestAnimationFrame', () => {

describe('setImmediate', () => {
test('fakes setImmediate', () => {
// Jasmine runner does not handle unhandled promise rejections that are causing the test to fail in Jest circus
const expectedExitCode = isJestJasmineRun() ? 0 : 1;

const result = runJest('fake-timers-legacy/set-immediate');

expect(result.stderr).toMatch('setImmediate test');
expect(result.exitCode).toBe(expectedExitCode);
expect(result.exitCode).toBe(0);
});
});

Expand Down