I have a specific requirement to use two different data files per environment (stage.json & prod.json) in such a way that when I use stage env, data should come from stage.json & when I use prod env, data should come from prod.json. I have created a framework in Cypress using Mocha. I checked tutorials of Cypress but could not find relevant information. I also googled out but no luck. I would appreciate any help here.
What about using plain JS :
if (process.env.NODE_ENV === 'development') {
// do dev stuff
}
if (process.env.NODE_ENV === 'production') {
//do production stuff
}
I guess you could find a trick, based on this logic, to differenciate staging from prod. I don't think that Cypress itself could handle that.
I hope this could help
Take a look at Configuration
Change Configuration File
You can change the configuration file or turn off the use of a configuration file by using the --config-file flag.
cypress open --config-file <config-file>
So, have your staging in cypress.json then to run prod call cypress run --config-file prod.json.