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

Cannot run jest tests with --maxWorkers=50% option via @nrwl/jest:jest builder #2871

Closed
wrslatz opened this issue Apr 18, 2020 · 4 comments · Fixed by #3025
Closed

Cannot run jest tests with --maxWorkers=50% option via @nrwl/jest:jest builder #2871

wrslatz opened this issue Apr 18, 2020 · 4 comments · Fixed by #3025
Labels
community This is a good first issue for contributing outdated scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx type: feature

Comments

@wrslatz
Copy link
Contributor

wrslatz commented Apr 18, 2020

The @nrwl/jest builder should support both number and string inputs for maxWorkers config option. Passing --maxWorkers=50% to ng test or nx affected:test fails with schema validation, but the Jest CLI Options documentation specify that both a number and string are acceptable arguments.

Expected Behavior

Both ng test -- --maxWorkers=50% and nx affected:test -- --maxWorkers=50% run tests and do not throw schema validation errors.

Current Behavior

Both ng test -- --maxWorkers=50% and nx affected:test -- --maxWorkers=50% result in the following error:

Cannot parse arguments. See below for the reasons.
    Argument --maxWorkers could not be parsed using value "50%".Valid type(s) is: number

Failure Information (for bugs)

Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.

Steps to Reproduce

  1. npx create-nx-workspace@latest
  2. Choose a workspace that has tests out of the gate (I chose Angular)
  3. Run any test using "builder": "@nrwl/jest:jest" and pass -- --maxWorkers=50% flag to the command.

Context

The schema that is now out of date

"maxWorkers": {
"alias": "w",
"description": "Specifies the maximum number of workers the worker-pool will spawn for running tests. This defaults to the number of the cores available on your machine. Useful for CI. (its usually best not to override this default) (https://jestjs.io/docs/en/cli#maxworkers-num)",
"type": "number"

The original PR that implemented this functionality
#757

The latest jest docs for this functionality
https://jestjs.io/docs/en/cli#--maxworkersnumstring

Minimal reproduction repo
https://github.com/wrslatz/nx-playground/tree/e836200fe7484c6ac022066d13d534f5eb95808b

@FrozenPandaz FrozenPandaz added community This is a good first issue for contributing scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx type: feature labels May 1, 2020
@FrozenPandaz
Copy link
Collaborator

Thanks for reporting this!

Looks like the type of the option needs to be number | string

This would be a good first issue.

@wrslatz
Copy link
Contributor Author

wrslatz commented May 1, 2020

I'd be happy to submit a PR for review!

wrslatz added a commit to wrslatz/nx that referenced this issue May 17, 2020
… type

Jest supports both number and string args for the maxWorkers option, per their latest docs. This
updates the options for the jest builder to support both number and string types. Also updates the
docs accordingly.

ISSUES CLOSED: nrwl#2871
wrslatz added a commit to wrslatz/nx that referenced this issue May 17, 2020
… type

Jest supports both number and string args for the maxWorkers option, per their latest docs. This
updates the options for the jest builder to support both number and string types. Also updates the
docs accordingly.

ISSUES CLOSED: nrwl#2871
wrslatz added a commit to wrslatz/nx that referenced this issue May 17, 2020
… type

Jest supports both number and string args for the maxWorkers option, per their latest docs. This
updates the options for the jest builder to support both number and string types. Also updates the
docs accordingly.

ISSUES CLOSED: nrwl#2871
@wrslatz
Copy link
Contributor Author

wrslatz commented May 20, 2020

I've submitted #3025 to close this issue. Would appreciate a review whenever it's convenient!

FrozenPandaz pushed a commit that referenced this issue May 23, 2020
… type (#3025)

* fix(testing): update maxWorkers jest builder option to support string type

Jest supports both number and string args for the maxWorkers option, per their latest docs. This
updates the options for the jest builder to support both number and string types. Also updates the
docs accordingly.

ISSUES CLOSED: #2871

* fix(testing): fix test expectation missing property
@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
community This is a good first issue for contributing outdated scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx type: feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants