Multiple configs with cypress 10.0 #23371
Replies: 2 comments 6 replies
-
I'm still working with multiple configs, helps me with more envs. What I did is that I have changed my exampleEnvConfig.json (lets say it's for test env) to exampleEnvConfig.js, and inside of it I have the same code as described in cypress.config.js (added some settings example here for e2e) Later in the package.json I just specify in the script which config file should be opened when running that specific script, again lets say we are targeting test env (--config-file cypress/config/exampleEnvConfig.js) When you run "npm run test" it will execute this script by opening cypress runner and using specified config.js. If you run "npx cypress open" it will run with cypress.config.js. I don't really use it but you can put some default config there in case someone runs without script. Dunno if this helps you, maybe someone has better approach but this works for me. |
Beta Was this translation helpful? Give feedback.
-
Since it's just JS now you could also do something like: import fs from 'fs-extra'
const config1 = fs.readJsonSync('./config1.json')
const config2 = fs.readJsonSync('./config12json')
export default defineConfig(
process.env.USE_CONFIG_1 ? config1 : config2
) Just an idea! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have multiple configs for different env in JSON format. then how we can achieve same thing with cypress 10. As per cypress migration video they did not talk about to migrate these config plans. any clue?
Beta Was this translation helpful? Give feedback.
All reactions