Open mohsen1 opened 1 year ago
Thank you for providing a repro. Im having a hard time understanding exactly what the problem is though. The screenshot below shows the cypress.config.ts
file and the run-cypress.js
script which alters the config file and then the terminal output which prints the altered config from the run-cypress.js
file. Can you be more specific on where the problem lies?
@jordanpowell88 The problem is the cypress.config.js
file is being loaded again (using a require
call somewhere in Cypress module)
node run-cypress.js
Note the line console.trace('cypress.config.js is read');
was invoked twice even though my code requires this file only once. You can see in the trace that it is being required from within Cypress module for the second time.
For most people this is not a problem but for our case -- since we use Cypress CLI programmatically this is causing issues.
@mohsen1 I was able to reproduce what you are seeing. Thanks for the reproduction. It looks like Cypress needs to see that the configuration is being passed in programmatically and not load the config again.
Current behavior
Cypress reading the config file even when it is invoked programmatically and has the config passed in
I've created a minimal repo to demonstrate the current behavior:
https://github.com/mohsen1/cypress-programming-api-
Desired behavior
When invoking Cypress programmatically using
cypress.open
orcypress.run
and passing the config object we're expecting Cypress to leave thecypress.config.js
alone since we've passed the configuration.Why this is a problem?
We have a complicated flow for running Cypress. We read the config ourselves and do a bunch of modifications to the config before calling
cypress.run
. When Cypress is trying to read the config file again, we run into unexpected problems. Namely Cypress fails to understand our custom imports.Test code to reproduce
https://github.com/mohsen1/cypress-programming-api-
Cypress Version
11
Node version
16
Operating System
macOS, Linux
Debug Logs
No response
Other
No response