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

feat: allow runInBand to be configured at project level #10912

Closed
wants to merge 13 commits into from

Conversation

freshollie
Copy link

@freshollie freshollie commented Dec 3, 2020

Summary

Peek 2021-10-17 12-49

Lots of feedback from people looking for this feature in #10936

Currently running tests in band has to be configured on a global level through --runInBand arg.

This doesn't take into account some projects (particularly monorepos) which may need to be granular in this setting at a project level, some packages may be able to run tests in parallel, while others, integration tests for example, may require that all tests are run serially.

Because jest already has the mechanism to run tests across multiple projects, it makes sense that this setting is available to be switched on at a per project level, where the overall test strategy will be in parallel, but tests in an individual project will run in serial.

Example

module.exports = {
  "projects": [
    {
      "displayName": "integration",
      "testEnvironment": "node",
      "runInBand": true,
      "testMatch": [ "**/__integration__/**/*.[jt]s?(x)", "**/?(*.)+(integration).[jt]s?(x)" ]
    },
    {
      "displayName": "e2e",
      "testEnvironment": "node",
      "runInBand": true,
      "testMatch": [ "**/__e2e__/**/*.[jt]s?(x)", "**/?(*.)+(e2e).[jt]s?(x)" ]
    },
    {
      "displayName": "unit",
      "testEnvironment": "node"
    }
  ]
}

Test plan

  • Add unit tests
  • Fix failing tests
  • Update snapshots
  • Create e2e test

@facebook-github-bot
Copy link
Contributor

Hi @freshollie!

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file.

In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@freshollie freshollie marked this pull request as draft December 3, 2020 23:48
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

1 similar comment
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@freshollie freshollie changed the title feat: allow runInBand to be configured at a per project level [WIP] feat: allow runInBand to be configured on a project level [WIP] Dec 4, 2020
@freshollie
Copy link
Author

freshollie commented Dec 4, 2020

@SimenB Looking for feedback before continuing fixing/writing tests. POC works, but is this something you would consider in the main codebase?

Splitting this into a runner is possible, but requires mostly duplicating logic already found in jest-runner, and without this change there is no way to use the project config to determine how each individual project should be executed.

@freshollie freshollie changed the title feat: allow runInBand to be configured on a project level [WIP] feat: allow runInBand to be configured on a per project level [WIP] Dec 4, 2020
@freshollie freshollie changed the title feat: allow runInBand to be configured on a per project level [WIP] feat: allow runInBand to be configured per project [WIP] Dec 4, 2020
@freshollie freshollie changed the title feat: allow runInBand to be configured per project [WIP] feat: allow runInBand to be configured per project [RFC] Dec 13, 2020
@codecov-commenter
Copy link

codecov-commenter commented Jul 4, 2021

Codecov Report

Merging #10912 (eb49789) into main (b89a1bb) will increase coverage by 0.00%.
The diff coverage is 64.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #10912   +/-   ##
=======================================
  Coverage   66.97%   66.98%           
=======================================
  Files         329      329           
  Lines       17341    17355   +14     
  Branches     5066     5070    +4     
=======================================
+ Hits        11615    11625   +10     
- Misses       5694     5698    +4     
  Partials       32       32           
Impacted Files Coverage Δ
packages/jest-config/src/Defaults.ts 100.00% <ø> (ø)
packages/jest-config/src/ValidConfig.ts 100.00% <ø> (ø)
packages/jest-config/src/index.ts 20.73% <ø> (ø)
packages/test-utils/src/config.ts 0.00% <ø> (ø)
packages/jest-runner/src/index.ts 63.44% <52.63%> (-0.85%) ⬇️
packages/jest-config/src/normalize.ts 88.92% <100.00%> (+0.02%) ⬆️
packages/jest-core/src/testSchedulerHelper.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b89a1bb...eb49789. Read the comment docs.

@freshollie freshollie changed the title feat: allow runInBand to be configured per project [RFC] feat: allow runInBand to be configured at project level Oct 17, 2021
### `runInBand` [boolean]

Default: `false`

This option allows the test runner to know how it runs your tests at a project level.

Sometimes it's desirable for a specific package within your repository to run tests in band, such as integration tests, and for other packages in the same repository to run tests in parallel.

When configured in the root jest configuration, all tests will be run in band.

Copy link
Author

Choose a reason for hiding this comment

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

I've tried to describe the usage here, but looking for feedback

@@ -0,0 +1,76 @@
/**
Copy link
Author

Choose a reason for hiding this comment

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

These tests could be moved to multi-project e2es, found it simpler to keep them separate

"description": "Testing the behaviour of runInBand at project level",
"jest": {
"projects": ["./*/jest.config.js"],
"maxWorkers": 9
Copy link
Author

Choose a reason for hiding this comment

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

Ensure that under normal circumstances, all tests would be run at the same time

@freshollie freshollie marked this pull request as ready for review October 17, 2021 12:02
@revmischa
Copy link

revmischa commented Oct 26, 2021

This would be extremely useful for me, having integration tests in a monorepo. My life will get better when this is merged.

@freshollie
Copy link
Author

@SimenB @thymikee any chance I could get some eyes on this please :)

It's got a large amount of traction but no feedback. PR has e2es and Unit tests.

Would be good to know if I should continue to maintain this change.

@revmischa
Copy link

@SimenB @thymikee can we possibly get this merged? I really need this feature.

@freshollie
Copy link
Author

@revmischa I'm considering re-opening this PR it seems to have been buried...

@github-actions
Copy link

This PR is stale because it has been open 1 year 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 Mar 17, 2023
@revmischa
Copy link

It's fine, switching to vitest greatly improved my life

@github-actions github-actions bot removed the Stale label Mar 17, 2023
@freshollie
Copy link
Author

@revmischa same lol

@tsa96
Copy link

tsa96 commented Apr 17, 2023

Still something that'd be useful to me, how has it gone ignored for so long? Bumping to keep alive, don't know why fully fleshed out PR is being closed by a bot after having absolutely no feedback from a maintainer. @SimenB @thymikee

Copy link

This PR is stale because it has been open 1 year 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 Apr 16, 2024
@freshollie
Copy link
Author

Sorry all, got no feedback on this and I'm no longer interested in using Jest. We've found vitest fits all our use cases.

@freshollie freshollie closed this Apr 25, 2024
Copy link

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

Successfully merging this pull request may close these issues.

5 participants