Many cypress tests on different web applications and frontend teams here at twilio sendgrid. As our testing expanded into many features and pages, we came across some useful configuration options and developed ways to better manage our growing number of files, our page element selectors, and timeout values along the way. Our goal is to show you these tips and ideas for setting up, organizing, and consolidating your own cypress-related stuff, so feel free to make it what works best for you and your team.
This blog post assumes that you have a working knowledge of cypress testing and are looking for ideas to better maintain and improve your cypress testing. However, if you're company mailing list curious to learn more about common functions, assertions, and patterns that you might find useful for writing cypress tests in separate environments, you can check out this thousand foot overview blog post at square. If not, let's move on and explain some configuration tips for cypress first. Configuring your cypress.Json the file cypress.Jsonis where you can set all the configuration for your cypress tests,
Such as base timeouts for your cypress commands, environment variables, and other properties. Here are some tips to try in your setup: adjust the expiration times of your base commands, so you don't always have to add { timeout: timeoutinms }in your cypress commands. Tinker with the numbers until you find the right balance for settings like "Defaultcommandtimeout", "Requesttimeout", and "Responsetimeout". If your test involves iframes, you'll probably need to set "Chromewebsecurity" to false in order to be able to access cross-origin iframes in your app. Try blocking third-party marketing, analytics, and logging scripts when you run your cypress tests to increase speed and not trigger unwanted events.