I want to disable certain security features on my Vue front-end when Cypress is running tests. How can I detect in the Vue code that Cypress is running?
I'm sorry that I wasn't able to find this answer which must have already been asked, I did search for over 15 minutes before posting this issue!
Sure: https://docs.cypress.io/faq/questions/using-cypress-faq.html#Is-there-any-way-to-detect-if-my-app-is-running-under-Cypress
thanks
@vesper8 but please prefer to use env variables for cases where you want to add some additional logic to your application.
As in the case with window.Cypress (the one @bahmutov mentioned) all this code will land in your production bundle.
Maybe when the amount of additional cypress related code is not that big it's ok but if you want to add a lot of additional logic/routes you should prefer environment variables.
@desfero could you be so kind to reply with a short example of how to set env variables inside Cypress that are detectable inside the Vue application? thanks a lot!
Is it still working? window.Cypress is undefined to me after a couple of updates...
_edit_: never-mind, it simply started working again after a couple of restarts... thanks!
Most helpful comment
Sure: https://docs.cypress.io/faq/questions/using-cypress-faq.html#Is-there-any-way-to-detect-if-my-app-is-running-under-Cypress