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]: Jest Circus events are triggered in the wrong order when using test.concurrent #14616

Closed
madcapnmckay opened this issue Oct 13, 2023 · 6 comments

Comments

@madcapnmckay
Copy link
Contributor

Version

29.7.0

Steps to reproduce

  1. Clone repo at https://github.com/madcapnmckay/test-concurrent-bug-repro
  2. yarn install
  3. yarn test

Expected behavior

test_start & test_fn_start should execute before the test itself begins.

Here is the output for non-concurrent tests.

handleTestEvent setup
handleTestEvent add_hook
handleTestEvent add_test "Test 1"
handleTestEvent add_test "Test 2"
handleTestEvent run_start
handleTestEvent run_describe_start
handleTestEvent test_start "Test 1"
handleTestEvent test_started "Test 1"
handleTestEvent hook_start
handleTestEvent hook_success "Test 1"
handleTestEvent test_fn_start "Test 1"
  console.info
    "test 1 start

      at Object.<anonymous> (concurrent.test.ts:4:13)

  console.info
    "test 1 end

      at Object.<anonymous> (concurrent.test.ts:6:13)

handleTestEvent test_fn_success "Test 1"
handleTestEvent test_done "Test 1"
handleTestEvent test_start "Test 2"
handleTestEvent test_started "Test 2"
handleTestEvent hook_start
handleTestEvent hook_success "Test 2"
handleTestEvent test_fn_start "Test 2"
  console.info
    "test 2 start

      at Object.<anonymous> (concurrent.test.ts:10:13)

  console.info
    "test 2 end

      at Object.<anonymous> (concurrent.test.ts:12:13)

handleTestEvent test_fn_success "Test 2"
handleTestEvent test_done "Test 2"
handleTestEvent run_describe_finish
handleTestEvent run_finish
handleTestEvent teardown

Actual behavior

When running the same suite with test.concurrent

handleTestEvent setup
handleTestEvent add_hook
handleTestEvent add_test "Test 1"
handleTestEvent add_test "Test 2"
handleTestEvent run_start
handleTestEvent run_describe_start
  console.info
    "test 1 start

      at concurrent.test.ts:4:13

  console.info
    "test 1 end

      at concurrent.test.ts:6:13

  console.info
    "test 2 start

      at concurrent.test.ts:10:13

  console.info
    "test 2 end

      at concurrent.test.ts:12:13

handleTestEvent test_start "Test 1"
handleTestEvent test_started "Test 1"
handleTestEvent test_fn_start "Test 1"
handleTestEvent test_fn_success "Test 1"
handleTestEvent test_done "Test 1"
handleTestEvent test_start "Test 2"
handleTestEvent test_started "Test 2"
handleTestEvent test_fn_start "Test 2"
handleTestEvent test_fn_success "Test 2"
handleTestEvent test_done "Test 2"
handleTestEvent run_describe_finish
handleTestEvent run_finish
handleTestEvent teardown

The tests execute concurrently, but the circus events occur after they start.

Additional context

I noticed this while trying to write a custom jest environment for puppeteer and trying to take advantage of test.concurrent

Environment

System:
    OS: macOS 13.4.1
    CPU: (10) arm64 Apple M1 Max
  Binaries:
    Node: 18.14.2 - ~/.nvm/versions/node/v18.14.2/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.14.2/bin/yarn
    npm: 9.5.0 - ~/.nvm/versions/node/v18.14.2/bin/npm
    pnpm: 8.8.0 - ~/.nvm/versions/node/v18.14.2/bin/pnpm
  npmPackages:
    jest: ^29.7.0 => 29.7.0
@SimenB
Copy link
Member

SimenB commented Oct 13, 2023

Happy to take a PR 👍

@madcapnmckay
Copy link
Contributor Author

I have a potential fix but struggling to get yarn test to run on the v29.7.0 branch.

Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Nov 22, 2023
Copy link

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 22, 2023
Copy link

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

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 Jan 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants