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]: CLI: --outputFile multiple times causes crash #13611

Closed
vszabo2 opened this issue Nov 14, 2022 · 4 comments
Closed

[Bug]: CLI: --outputFile multiple times causes crash #13611

vszabo2 opened this issue Nov 14, 2022 · 4 comments

Comments

@vszabo2
Copy link

vszabo2 commented Nov 14, 2022

Version

29.3.1 and also main (6fc1860)

Steps to reproduce

  1. Clone my repo at https://github.com/vszabo2/jest-crash.git
  2. npm install
  3. npm test

You should see what I see, an internal error in Jest.

Expected behavior

I expect one of the following to occur:

  • Jest gives an error saying that it is invalid to specify --outputFile multiple times
  • Jest runs normally and writes JSON output to either output1.json or output2.json
  • Jest runs normally and writes JSON output to both output1.json and output2.json

Actual behavior

The tests run successfully, but then the error with the following stack trace occurs, before any output files are written:

TypeError: The "path" argument must be of type string. Received an instance of Array
    at new NodeError (node:internal/errors:371:5)
    at validateString (node:internal/validators:120:11)
    at Object.resolve (node:path:1098:7)
    at processResults (/home/victor/git/jest-crash/node_modules/@jest/core/build/runJest.js:184:31)
    at runJest (/home/victor/git/jest-crash/node_modules/@jest/core/build/runJest.js:358:9)
    at _run10000 (/home/victor/git/jest-crash/node_modules/@jest/core/build/cli/index.js:326:7)
    at runCLI (/home/victor/git/jest-crash/node_modules/@jest/core/build/cli/index.js:191:3)
    at Object.run (/home/victor/git/jest-crash/node_modules/jest-cli/build/run.js:124:37)

Additional context

No response

Environment

System:
    OS: Linux 5.19 Arch Linux
    CPU: (8) x64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
  Binaries:
    Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.14.0/bin/yarn
    npm: 8.3.1 - ~/.nvm/versions/node/v16.14.0/bin/npm
  npmPackages:
    jest: 29.3.1 => 29.3.1
@vszabo2
Copy link
Author

vszabo2 commented Nov 14, 2022

I think the root of this issue is the call to yargs in run.ts (link). The object that yargs returns does not match the Config.Argv type. If --outputFile is passed on the command line multiple times, the outputFile property is an array, which should normally not be assignable to the declared type of outputFile, which is string. This may happen with other options/properties too.

Here are some links from the argument parsing dependency which are relevant:
Documentation: https://github.com/yargs/yargs/blob/main/docs/tricks.md#arrays
Config: https://github.com/yargs/yargs-parser#duplicate-arguments-array
Discussion: yargs/yargs#530 yargs/yargs#229

@github-actions
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 Dec 14, 2022
@github-actions
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 Jan 13, 2023
@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 Feb 13, 2023
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

1 participant