Jest: Using --testURL as a CLI option results in Unrecognized CLI Parameter"

Created on 29 Aug 2019  Ā·  11Comments  Ā·  Source: facebook/jest

Bug Report

When running jest via the command line with a --testURL argument it says the parameter is unrecognized.

╭─zg@a-computer ~/repos/test 
╰─$ jest --testURL "https://localhost"                                                                                                                                                              128 ↵
ā— Unrecognized CLI Parameter:

  Unrecognized option "testURL". Did you mean "testURL"?

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

To Reproduce

Install jest and then run jest --testURL "https://localhost"

Expected behavior

Jest runs with the appropriate testURL as part of the configuration

envinfo

╭─zg@a-computer ~/repos/test 
╰─$ npx envinfo --preset jest
npx: installed 1 in 10.374s

  System:
    OS: macOS 10.14.6
    CPU: (4) x64 Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz
  Binaries:
    Node: 10.2.1 - ~/.nvm/versions/node/v10.2.1/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 5.6.0 - ~/.nvm/versions/node/v10.2.1/bin/npm
Bug Help Wanted good first issue

Most helpful comment

Arguments starting with a -- (double dash) are commonly referred to as "long options". If they expect an argument you usually would "assign" it.[1] So in this case you would have to use --testURL="http://localhost". This works at least on latest master. The error message in this case should explain that an argument was expected but none was received.

All 11 comments

Haha, what a dumb error šŸ˜… Workaround: jest --config '{"testURL": "https://localhost"}'.


Do you wanna send a PR fixing this? The error is here: https://github.com/facebook/jest/blob/95688ac9c81c19ca1bbda3aaad2a278c2a60461f/packages/jest-validate/src/validateCLIOptions.ts#L80-L89

In particular, making sure to check allowedOptions both with _and_ without camelcase seemingly fixes this issue from my quick editing in node_modules.

My coworker, @cchanse, would like to take a stab at it

That's awesome, go for it!

Arguments starting with a -- (double dash) are commonly referred to as "long options". If they expect an argument you usually would "assign" it.[1] So in this case you would have to use --testURL="http://localhost". This works at least on latest master. The error message in this case should explain that an argument was expected but none was received.

Can i help in this issue in someway?

I will take this up.

@SimenB I made a change are wrote a unit test for same. How can I run a single unit test only?

May I work on this issue?

@victorphoenix3 yes!

@victorphoenix3 let me know if you're not working on it, I'd love to take a try šŸ˜„

Hi @alexkubica ! I am almost done with the PR. Maybe you could help review it :)

Was this page helpful?
0 / 5 - 0 ratings