-
Notifications
You must be signed in to change notification settings - Fork 115
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 execution is not exiting on npx run without package.json file #120
Comments
@benophilipmathew Thank you for reporting this! I will take a look. Can I ask: why do you have no package.json? In my experience this is not very common at all to see (e.g. relying a node_module without a package.json present). |
I'm not able to reproduce this error locally using OS X. Are you running this on windows by chance? The only other mention of someone seeing jest-junit never exit was reported on Windows. |
Hello @palmerj3, Yes, I am running it on Windows (locally & build server). I totally agree with you, this is not a very common scenario and I come across this while creating release pipeline for my frontend tests which is driven through puppeteer (where I want to test stuff after deployment and that's why I am copying only a few files, installing only required package and running it through npx) Anyway, my final version will definitely have a package.json and this is not something that can block me but curious to know what kind of dependency we have on package.json |
@benophilipmathew I don't have a windows machine to test with, unfortunately, but I should have access to one after the holidays so I'll leave this issue open until then. |
I ran into this exact problem this evening while testing a Yeoman generator I had written. I'm using Jest as my test framework, and I use jest-junit to produce JUnit test result files that I can upload to Azure Pipelines. In my situation running on Windows 10, the Yeoman test helpers will create a temp directory under my user AppData\Local\Temp folder, change into that directory, and then run the generator under test within that. The Yeoman test helpers then give you different assertion helpers you can you use to make sure your generator actually produces the files you expect. When jest-junit runs, it'll eventually call getAppOptions and pass for the return Object.assign({}, constants.DEFAULT_OPTIONS, reporterOptions, getAppOptions(process.cwd()), getEnvOptions()); That call eventually does a walk up the directory hierarchy looking for a package.json file. It's supposed to stop when it hits the root of the file system, but it looks like it's checking that by comparing against traversing = pathToResolve !== path.sep; That'll work (presumably) fine on Unix-based OSes where the file system root is |
@mvromer , would this recent commit fix this issue ? #215 also @benophilipmathew |
Hi Guys,
Recently I was setting up azure release pipeline for my jest tests and found that the task execution is not exiting while running jest through npx. Later I found jest-junit reporter is causing this issue.
However, the interesting part is npx run with an empty package.json file will work as expected
Note - This is only happening with jest-junit package if we run without jest-junit it will run fine
How to reproduce-
step 1 - git clone https://[email protected]/benophilipmathew_dl/jest-junit-issue.git
step 2 - npm i jest jest-junit
step 3 - npx jest --maxWorkers=1 --forceExit
I am using node - 13.3.0 but I guess, it's the same with all other versions
expected result - test execution should stop after a successful run
actual result - test execution will never stop
How I fixed this - added an empty (i.e. {}) package.json in the working folder and it started working as expected
Any idea why the empty package.json file is doing this magic?
The text was updated successfully, but these errors were encountered: