`--config` changes working directory, Cypress 9 -> 10/11/12
See original GitHub issueCurrent 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-cwd
for previous functionality: https://github.com/AriPerkkio/vite-everything/commit/0e282c86eefa3766f25b374f5562518e6ecce3db - Branch
test/cypress-10-after-run-cwd
for current funcionality: https://github.com/AriPerkkio/vite-everything/commit/dbead4b1c90a107f2dbea6cbea454d3ccc89e5da
yarn # Install dependencies
yarn test:component # Run Cypress Component Test Runner
Cypress Version
10.3.0
Other
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:10 (1 by maintainers)
Top Results From Across the Web
Configuration - Cypress Documentation
This gives you the ability to change configuration options without modifying any code or build scripts. For example, these enviroment variables in the...
Read more >cypress-io/cypress - CircleCI Developer Hub
Run your Cypress.io end-to-end & component tests without spending time configuring CircleCI. This orb can also record results on the Cypress ...
Read more >Integrate Cypress with Universal Agent - Tricentis
For Windows, open the command prompt. Navigate to the source code folder. For Mac or Linux, navigate to cd /usr/local/var/cypress-sample ...
Read more >Configurations in Cypress and How to Disable Default ...
What are the default Configurations for folder/files provided by ... Cypress provides two ways to override/change the configuration values:.
Read more >Tutorial - Set up fullstack project - Vue - AWS Amplify Docs
12345678910111213141516. npm init vue@3 Need to install the following packages: create-vue@3 Ok to proceed? (y) y β Project name: β¦ myamplifyproject β AddΒ ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@gsouf thatβs best solution for now.
I really want to keep Cypress configuration file under a sub directory
config/
since thatβs where I store configuration files for all sorts of tooling. So as a work-around Iβm now using a separate configuration file in project root which simply imports the actual config. This way I donβt need to apply any other work-arounds, e.g. prefixing all paths with.../../
or runningprocess.chdir()
anywhere.@jhpedemonte maybe it is simpler to keep the config file at the root until this is fixed?