Skip to content

Commit

Permalink
Revert "Prevent false test failures caused by promise rejections hand…
Browse files Browse the repository at this point in the history
…led asynchronously (jestjs#14110)" (jestjs#14304)
  • Loading branch information
SimenB committed Jul 6, 2023
1 parent 596422e commit 208f2f1
Show file tree
Hide file tree
Showing 28 changed files with 21 additions and 770 deletions.
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

0 comments on commit 208f2f1

Please sign in to comment.