cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.06k stars 3.19k forks source link

Cypress encountered an error while parsing the argument: --spec #22732

Open F3n67u opened 2 years ago

F3n67u commented 2 years ago

Current behavior

I made a mistake to pass an empty string to the --browser option of cypress run, but the error message says that I pass a wrong --spec option, this is very confusing.

$ npx cypress run --browser  --spec "cypress/integration/1-getting-started/todo.spec.js" 

[95081:0711/163933.485060:ERROR:node_bindings.cc(276)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.
[95081:0711/163933.485081:ERROR:node_bindings.cc(276)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.
[95081:0711/163933.485088:ERROR:node_bindings.cc(276)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.
Cypress encountered an error while parsing the argument: --spec

You passed: true

The error was: spec must be a string or comma-separated list

Desired behavior

In this situation, cypress should say that the value of --browser options is not valid.say

Test code to reproduce

$ npx cypress run --browser  --spec "cypress/integration/1-getting-started/todo.spec.js" 

Cypress Version

10.3.0

Other

$ npx cypress -v                                                                         
Cypress package version: 10.3.0
Cypress binary version: 10.3.0
Electron version: 18.3.0
Bundled Node version: 16.13.2
BlueWinds commented 2 years ago

That is rather strange. Repro is pretty easy, exactly as described (given spec doesn't have to exist). Looks like something in our CLI is getting confused by --browser --spec - we could probably throw a more useful error. Pull requests welcome, but I doubt the team will prioritize this.

mschile commented 1 year ago

We use the commander package and this is the default behavior. I believe we would have to write custom parsers for the options to handle this use-case.

lunaautomation commented 8 months ago

I am going to give this one a try 👋