Closed
Description
Current behavior:
When passing --config-file cypress.json
as part of the command line arguments to parseRunArguments, cypress fails with the following error:
The "path" argument must be of type string. Received type boolean
TypeError [ERR_INVALID_ARG_TYPE] [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type boolean
Desired behavior:
The --config-file argument should be properly parsed also when using the node module API.
Test code to reproduce
const cypress = require('cypress');
async function reproduceError() {
const runOptions = await cypress.cli.parseRunArguments(['cypress', 'run', '--config-file', 'cypress.json']);
const results = await cypress.run(runOptions);
}
reproduceError();
Versions
Cypress 5.2.0
Windows 10
Analysis
With debugging it is clear where the issue appears:
cypress:cli:cli parsing args: [ null, null, 'run', '--config-file=myConfigFile.json' ] +3ms
...
cypress:cli parsed cli options { configFile: 'myConfigFile.json' } +0ms
cypress:cli:cli parsed options { configFile: 'myConfigFile.json' } +46ms
cypress:cli:cli casted options { configFile: true } +1ms
`
Looking through the code, there is a coercion function applied to the configFile property when parsing arguments, since this argument may be a string or false. However, the coercion function always returns a boolean
Lines 25 to 27 in ef2363e
Suggested fix
If the coercion function is replaced with
const coerceFalse = (arg) => {
return arg !== 'false' ? arg : false;
}
it should work as expected.
Activity
bahmutov commentedon Sep 21, 2020
Good catch @bjowes - do you mind opening a pull request with this fix and a corresponding unit test?
bjowes commentedon Sep 21, 2020
Sure, why not. Would be nice to be able to claim that I have contributed to the cypress code base :)
bahmutov commentedon Sep 21, 2020
cypress-bot commentedon Sep 22, 2020
The code for this is done in cypress-io/cypress#8636, but has yet to be released.
We'll update this issue and reference the changelog when it's released.
cypress-bot commentedon Sep 29, 2020
Released in
5.3.0
.This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v5.3.0, please open a new issue.