-
Couldn't load subscription status.
- Fork 3.4k
Description
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 actual cypress 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.
/workspaces/vite-everything
└── config
└── cypress
├── component-index.html
├── cypress.config.ts
├── support.component.ts
└── support.ts
cypress run --component --config-file config/cypress/cypress.config.ts
// config/cypress/cypress.config.ts
setupNodeEvents(on) {
on('after:run', () => {
console.log('[after:run] cwd is', process.cwd());
// > [after:run] cwd is /workspaces/vite-everything/config/cypress
});
},Desired behavior
The current working directory should match with Cypress 9.
/workspaces/vite-everything
└── config
└── cypress
├── cypress.json
├── plugins.ts
└── support.ts
cypress run-ct --config-file config/cypress/cypress.json
// config/cypress/plugins.ts
on('after:run', () => {
console.log('[after:run] cwd is', process.cwd());
// [after:run] cwd is /workspaces/vite-everything
});Test code to reproduce
I run into this error in separate closed source project but here is another project for reproducing the issue:
- https://github.com/AriPerkkio/vite-everything
- Branch
test/cypress-9-after-run-cwdfor previous functionality: AriPerkkio/vite-everything@0e282c8 - Branch
test/cypress-10-after-run-cwdfor current funcionality: AriPerkkio/vite-everything@dbead4b
yarn # Install dependencies
yarn test:component # Run Cypress Component Test Runner
Cypress Version
10.3.0
Other
No response