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

[Bug]: test.concurrent.each not executing tests concurrently #12068

Closed
gergo-seedcx opened this issue Nov 15, 2021 · 7 comments · Fixed by #12748
Closed

[Bug]: test.concurrent.each not executing tests concurrently #12068

gergo-seedcx opened this issue Nov 15, 2021 · 7 comments · Fixed by #12748

Comments

@gergo-seedcx
Copy link

gergo-seedcx commented Nov 15, 2021

Version

v27.3.1

Steps to reproduce

import { setTimeout } from 'timers/promises';

test.concurrent.each([1, 2, 3, 4, 5])(
  'concurrency test',
  async () => {
    await setTimeout(1000);
    expect(true).toBe(true);
  },
);
 PASS  src/a.spec.ts (5.457 s)
  ✓ concurrency test (1004 ms)
  ✓ concurrency test (1001 ms)
  ✓ concurrency test (1002 ms)
  ✓ concurrency test (1002 ms)
  ✓ concurrency test (1000 ms)

Test Suites: 1 passed, 1 total
Tests:       5 passed, 5 total
Snapshots:   0 total
Time:        5.653 s, estimated 6 s

Expected behavior

I expect test run time to be around 1 second

Actual behavior

Based on the run time tests seem to be run in sync.

Additional context

No response

Environment

System:
    OS: Linux 4.19 Ubuntu 20.04.3 LTS (Focal Fossa)
    CPU: (16) x64 AMD Ryzen 7 4800H with Radeon Graphics
  Binaries:
    Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
    npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
  npmPackages:
    jest: ^27.3.1 => 27.3.1
@gergo-seedcx gergo-seedcx changed the title [Bug]: test.concurrent.each not esecuting tests concurrently [Bug]: test.concurrent.each not executing tests concurrently Nov 15, 2021
@matheo
Copy link

matheo commented Nov 22, 2021

I'm having a related issue because right now my CI feels like runInBand or like my test runner is serial but I'm not sure how to check that, it feels that something is forcing the sequential execution.

@bogdbo
Copy link

bogdbo commented Dec 14, 2021

I'm having same issue at the moment. It seems doing something around the lines of (see below) works but doesn't seem to respect maxConcurrency value.

[1,2,3,4,5].forEach(() => {
  test.concurrent('test', async () => {
    return new Promise(resolve => {
      setTimeout(() => resolve(1), 1000);
    });
  });
});

@SimenB
Copy link
Member

SimenB commented Dec 15, 2021

Hmm, seems #8985 wasn't actually fixed...

/cc @Mark1626 any idea?

@Liorvais1
Copy link

Liorvais1 commented Dec 22, 2021

Can't really tell where the problem is, but I can tell that when trying on (quite old) version
"jest": "^26.6.3"
it does work:
✓ concurrency test (1001 ms)
✓ concurrency test (1 ms)
✓ concurrency test
✓ concurrency test
✓ concurrency test (1 ms)

Test Suites: 1 passed, 1 total
Tests: 5 passed, 5 total
Snapshots: 0 total
Time: 1.569 s, estimated 2 s

When trying to use
"jest": "^27.0.0"
and above, the concurrency fails as explained

@Mark1626
Copy link
Contributor

It seems to be in jest-circus after version v27.0.0.

It works fine for me with jest-jasmine2 in v27.0.0.

Can another person try this with jest-jasmine2, to confirm it's only in jest-circus?

// jest.config.js
{
  "testRunner": "jest-jasmine2"
}

With jest-jasmine:

 PASS  ./each.test.js
  ✓ concurrency test (998 ms)
  ✓ concurrency test
  ✓ concurrency test
  ✓ concurrency test (1 ms)
  ✓ concurrency test

Test Suites: 1 passed, 1 total
Tests:       5 passed, 5 total
Snapshots:   0 total
Time:        1.279 s, estimated 6 s

@bogdbo
Copy link

bogdbo commented Jan 26, 2022

Thanks @Mark1626. I have verified this with jest-jasmine2 and everything works as expected. 👍️

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants