Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
### Fixes

- `[expect]` Allow again `expect.Matchers` generic with single value ([#11986](https://github.com/facebook/jest/pull/11986))
- `[jest-circus, jest-jasmine2]` Avoid false concurrent test failures due to unhandled promise rejections ([#11987](https://github.com/facebook/jest/pull/11987))
- `[jest-config]` Add missing `slash` dependency to `package.json` ([#12080](https://github.com/facebook/jest/pull/12080))
- `[jest-core]` Incorrect detection of open ZLIB handles ([#12022](https://github.com/facebook/jest/pull/12022))
- `[jest-diff]` Break dependency cycle ([#10818](https://github.com/facebook/jest/pull/10818))
Expand Down
9 changes: 9 additions & 0 deletions e2e/__tests__/jasmineAsync.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,13 @@ describe('async jasmine', () => {

expect(result.exitCode).toBe(0);
});

it('works when another test fails while one is running', () => {
const {json} = runWithJson('jasmine-async', [
'concurrent-parallel-failure.test.js',
]);
expect(json.numTotalTests).toBe(2);
expect(json.numPassedTests).toBe(1);
expect(json.numFailedTests).toBe(1);
});
});
16 changes: 16 additions & 0 deletions e2e/jasmine-async/__tests__/concurrent-parallel-failure.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

it.concurrent('Good Test', async () => {
await new Promise(r => setTimeout(r, 100));
});

it.concurrent('Bad Test', async () => {
expect('a').toBe('b');
});
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ export const initialize = async ({
// that will result in this test to be skipped, so we'll be executing the promise function anyway,
// even if it ends up being skipped.
const promise = mutex(() => testFn());
// Avoid triggering the uncaught promise rejection handler in case the test errors before
// being awaited on.
promise.catch(() => {});
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this doesn't mean promise will never reject, that is only true for the promise returned by catch(...).

globalsObject.test(testName, () => promise, timeout);
};

Expand Down
3 changes: 3 additions & 0 deletions packages/jest-jasmine2/src/jasmineAsyncInstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ function makeConcurrent(
} catch (error: unknown) {
promise = Promise.reject(error);
}
// Avoid triggering the uncaught promise rejection handler in case the test errors before
// being awaited on.
promise.catch(() => {});

return spec;
};
Expand Down