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

Jest v26 is failing when run without cli options #10014

Closed
basarbk opened this issue May 10, 2020 · 20 comments Β· Fixed by #11412
Closed

Jest v26 is failing when run without cli options #10014

basarbk opened this issue May 10, 2020 · 20 comments Β· Fixed by #11412

Comments

@basarbk
Copy link

basarbk commented May 10, 2020

πŸ› Bug Report

When running the jest without cli options, it's failing.

receiving following message in console

> jest

● Unrecognized CLI Parameters:

  Following options were not recognized:
  ["run-in-band", "test-location-in-results"]

  CLI Options Documentation:
  https://jestjs.io/docs/en/cli.html

npm ERR! Test failed.  See above for more details.

Problem is with version 26.0.1 (and 26.0.0). Same scenario is working with version 25.5.4.

To Reproduce

Followed the docs of jest. https://jestjs.io/docs/en/getting-started

Expected behavior

When no option is set, it is expected to run all tests.

Link to repl or repo (highly encouraged)

https://github.com/basarbk/jest-without-params-fail

envinfo

System:
OS: Windows 10 10.0.10240
CPU: (4) x64 Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz
Binaries:
Node: 12.13.1 - C:\Program Files\nodejs\node.EXE
npm: 6.13.1 - C:\Program Files\nodejs\npm.CMD
npmPackages:
jest: ^26.0.1 => 26.0.1

@thymikee
Copy link
Collaborator

Cannot repro. Run yarn test or npm run test and see it works. If you have global jest installed, please remove it, it's supposed to be installed locally per-project.

@SimenB
Copy link
Member

SimenB commented May 10, 2020

I cannot reproduce this

image

@basarbk
Copy link
Author

basarbk commented May 10, 2020

I don't have jest globally installed. It's just installed locally for this project. But it's interesting that it's only occuring in my machine. will look into it to figure out if I'm missing something.

@thymikee
Copy link
Collaborator

Maybe you have an alias set up?

@basarbk
Copy link
Author

basarbk commented May 10, 2020

No i don't have any alias matching to jest. The thing is if i replace 26.0.1 with 25.5.4, npm install --save-dev [email protected] and then run npm test again, it's working. So that's why I suspected something changed between these versions.

@SimenB
Copy link
Member

SimenB commented May 10, 2020

I don't have access to a windows machine, so I can't test there. We do run many tests on CI with Windows though, so I don't think it's as simple as that

@basarbk
Copy link
Author

basarbk commented May 10, 2020

I tested this on another windows machine and it's working there. So the problem must be about my environment. If I find the reason, I'll post it here. Thank you for your time.

@selimrecep
Copy link

image
I am experiencing same issue. I have created empty folder (no js files and other stuff) to verify that's not because of another something

@selimrecep
Copy link

Well I had to make a little change at built js files:
From:
test1
To:
test2
I couldn't find where are the args. coming from but I think they are from yarn(I didn't even install yarn so I don't know). But hey! At least it works very well :D

@basarbk
Copy link
Author

basarbk commented Jul 13, 2020

I had confirmed the problem was about my environment. But couldn't find the reason of it. Now my windows is reinstalled and I no longer see this issue. Previously I had jest globally installed then removed. Maybe that was causing the problem. Or maybe it was something about the caching of npm.

@vozzen
Copy link
Contributor

vozzen commented Jul 18, 2020

I've experienced same.
Problems is with host locale and camelcase dependency.
validateCLIOptions method in jest-validate\build\validateCLIOptions.js calls camelcase for each argv and tries to match them with allowed options. (see [this] line)(https://github.com/facebook/jest/blob/63ebaa6e3848ddf228b1acc6f870c7eaca34e46c/packages/jest-validate/src/validateCLIOptions.ts#L81)
When it calls camelcase for arg run-in-band, camelcase returns runΔ°nBand (capital 'i' in Turkish) if host has 'tr-TR' locale. And runΔ°nBand is not one of allowed options (although runInBand is).

Workaround for Win10: Settings > Region & Language > Adminstrative language settings > Formats.
Set Format to English (United States). That changes locale of node to en-US.

I guess proper solution would be camelcase providing locale option and jest-validate just provides en-US as locale.

@vozzen
Copy link
Contributor

vozzen commented Jul 18, 2020

Just created an issue in camelcase project as well.

@cemdrman
Copy link

I changed my language and it worked for me. sad but true.

@cbilgili
Copy link

cbilgili commented Feb 8, 2021

Adding the locale environment to test script works. You can update your test command in package.json

"scripts": {
    "test": "LANG='en_US.UTF-8' jest"
  }

@vahdet
Copy link

vahdet commented Apr 22, 2021

In package.json, adding --runInBand option is also a legit workaround for the time being. Adding that, the options won't be added behind the scene, and there will be no Turkish char problem:

/*package.json*/
"scripts": {
  "test": "jest --runInBand"
}

But expect a longer time to complete as it runs tests one by one

@SimenB
Copy link
Member

SimenB commented Apr 22, 2021

seems like we should pass locale to camelcase - anyone up for sending a PR?

@vozzen
Copy link
Contributor

vozzen commented Apr 22, 2021

Let me do it. It is really first issue, give me some time :)

@SimenB
Copy link
Member

SimenB commented Apr 22, 2021

Go for it @rasgele! πŸ™‚

@caglartufan
Copy link

Thanks @rasgele you have solved my problem as well just by changing some region settings. Δ°yi gΓΌnler! :)

SimenB pushed a commit that referenced this issue May 16, 2021
@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 Jun 16, 2021
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.

9 participants