-
Notifications
You must be signed in to change notification settings - Fork 3.3k
--config-file
changes working directory, Cypress 9 -> 10/11/12/13
#22689
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
Comments
after:run
task cwd changed after 9 -> 10
I've noticed the same incorrect working directory in |
I was able to reproduce this with the example repository provided |
Seeing this as well. It is impacting the use of |
I ran with
|
It appears that this is an intentional (but undocumented?) change in 10.0 (see app-lifecycle.md), wherein the config file is now run in a separate process, with |
@jhpedemonte I also run into this issue when using I'm not familiar with internals of Cypress but I think this is not intentional. A simple |
As per #23209 one of the issue in this ticket indicates that this behavior is probably not intended. ie. the default value for config |
FYI, my current workaround (until this is fixed either here or by plugins) is the following: function requirePluginWithProjectRoot(pluginPath, on, config) {
if (config.projectRoot) {
const cwd = process.cwd();
process.chdir(config.projectRoot);
require(pluginPath)(on, config);
// revert to previous cwd
process.chdir(cwd);
return;
}
throw Error("config.projectRoot doesn't exist");
} I only invoke this for requirePluginWithProjectRoot('@cypress/code-coverage/task', on, config); |
@jhpedemonte maybe it is simpler to keep the config file at the root until this is fixed? |
@gsouf that's best solution for now. I really want to keep Cypress configuration file under a sub directory
// TODO: Remove when https://github.com/cypress-io/cypress/issues/22689 is fixed
export { default } from './config/cypress/cypress.config'; |
after:run
task cwd changed after 9 -> 10--config
changes working directory, Cypress 9 -> 10/11/12
any updates? |
--config
changes working directory, Cypress 9 -> 10/11/12--config-file
changes working directory, Cypress 9 -> 10/11/12
--config-file
changes working directory, Cypress 9 -> 10/11/12--config-file
changes working directory, Cypress 9 -> 10/11/12/13
@MorisR nope, whole NPM adds // Work-around for https://github.com/cypress-io/cypress/issues/22689
if (!process.env.INIT_CWD) throw new Error('Missing INIT_CWD from npm');
process.chdir(process.env.INIT_CWD); I've been adding these lines to every single
|
Having this issue too |
Uh oh!
There was an error while loading. Please reload this page.
Current behavior
In
after:run
task, Cypress 10 is using the location of configuration file as current working directory. In Cypress 9 it is the root of project, or where the actualcypress run
command is run.After migrating from Cypress 9 to 10 some plugins I'm using started failing. They are relying on Cypress 9's functionality when it comes to current working directory, e.g. when reading files from disk.
I keep my
cypress.config.ts
in a separate folder - not in the project root.Desired behavior
The current working directory should match with Cypress 9.
Test code to reproduce
I run into this error in separate closed source project but here is another project for reproducing the issue:
test/cypress-9-after-run-cwd
for previous functionality: AriPerkkio/vite-everything@0e282c8test/cypress-10-after-run-cwd
for current funcionality: AriPerkkio/vite-everything@dbead4bCypress Version
10.3.0
Other
No response
The text was updated successfully, but these errors were encountered: