You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a test.concurrent test fails while another test is running, both tests report as failing with the same error. This occurs even if the failing test test is skipped with --testNamePattern (related to #10790?).
To Reproduce
Steps to reproduce the behavior:
Given a test that takes a second to pass, and another test that fails immediately:
test('addition of 2 numbers',async()=>{awaitnewPromise(resolve=>setTimeout(resolve,1000));// succeedsexpect(5+3).toBe(8);});test.concurrent('subtraction 2 numbers',async()=>{// failsexpect(5-3).toBe(3);});
Jest reports that addition of 2 numbers failed due to an error in subtraction 2 numbers
(node:333) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 2)
FAIL ./test.js
✕ addition of 2 numbers (1003 ms)
✕ subtraction 2 numbers (2 ms)
● addition of 2 numbers
expect(received).toBe(expected) // Object.is equality
Expected: 3
Received: 2
7 | test.concurrent('subtraction 2 numbers', async () => {
8 | // fails
> 9 | expect(5 - 3).toBe(3);
| ^
10 | });
at test.js:9:17
at Object.<anonymous> (test.js:7:6)
● subtraction 2 numbers
expect(received).toBe(expected) // Object.is equality
Expected: 3
Received: 2
7 | test.concurrent('subtraction 2 numbers', async () => {
8 | // fails
> 9 | expect(5 - 3).toBe(3);
| ^
10 | });
at test.js:9:17
at Object.<anonymous> (test.js:7:6)
Test Suites: 1 failed, 1 total
Tests: 2 failed, 2 total
Snapshots: 0 total
Time: 2.079 s, estimated 3 s
Ran all test suites.
Even if only the addition test runs, it still fails due to an error in the skipped subtraction test:
> jest "--testNamePattern" "addition"
FAIL ./test.js
✕ addition of 2 numbers (1004 ms)
○ skipped subtraction 2 numbers
● addition of 2 numbers
expect(received).toBe(expected) // Object.is equality
Expected: 3
Received: 2
7 | test.concurrent('subtraction 2 numbers', async () => {
8 | // fails
> 9 | expect(5 - 3).toBe(3);
| ^
10 | });
at test.js:9:17
at Object.<anonymous> (test.js:7:6)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 skipped, 2 total
Snapshots: 0 total
Time: 1.94 s, estimated 2 s
Ran all test suites with tests matching "addition".
Expected behavior
The failure should only be associated with the specific test that returned the rejected promise. In the example above, only subtraction 2 numbers should fail.
I came here to report the same error. This is the test I came up with to reproduce this:
test.concurrent('has a promise',async()=>{awaitnewPromise(r=>setTimeout(()=>r(true)))})test.concurrent('fails',()=>{expect(true).toBe(false)})
@also why is this labeled "Needs Repro"? Do you want me to send a PR with a failing test?
I'm not totally sure how to write a test for this, since we want one of the tests to fail (instead of two). Which means we want to write a test where "one test failing" means the test passes.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.
🐛 Bug Report
If a
test.concurrent
test fails while another test is running, both tests report as failing with the same error. This occurs even if the failing test test is skipped with--testNamePattern
(related to #10790?).To Reproduce
Steps to reproduce the behavior:
Given a test that takes a second to pass, and another test that fails immediately:
Jest reports that
addition of 2 numbers
failed due to an error insubtraction 2 numbers
Even if only the addition test runs, it still fails due to an error in the skipped subtraction test:
Expected behavior
The failure should only be associated with the specific test that returned the rejected promise. In the example above, only
subtraction 2 numbers
should fail.Link to repl or repo (highly encouraged)
https://replit.com/@also/jest-concurrent-bug
envinfo
in the replit linked above:
The text was updated successfully, but these errors were encountered: