Cypress is javascript framework for end to end testing of web applications. We have chosen it over other frameworks for its simplicity of use and setup. We even wrote a blog post with example about Cypress. In this article we share a few examples and tips that might help you.
Examples and tipsCustom commandsEnvironment variablesFixturesAdd screenshots and videos folders to gitignore
Examples and tips
Custom commands
Documentation
Custom commands are extremly usefull when you repeat same sequences of commands in more more tests. Why not to create a own command to avoid this repetition? They can be defined inÂ
cypress/support/commands.js
 file.Below is example with customÂ
authVisit
 command we use in almost every test to authenticate before navigating to a specific route/page.Environment variables
Documentation
Environment variables are useful for storing dynamic values that can be different for multiple development environments. In the example below we use it for storing REST API url which can naturally vary for different environments (development/stage).
Fixtures
Documentation
Fixtures are great for storing static test data (e.g. REST API responses/requests). They are defined in JSON files so you can easilly organize them.
Example with API response:
Add screenshots and videos folders to gitignore
When you run tests in command line usingÂ
cypress run
 command, it creates these two folders with images and videos from done tests. Adding it to .gitignore
 is recommended to save storage in your git repository.Â