DEV Community

Discussion on: Setting up Cypress

Collapse
 
mornir profile image
Jérôme Pott

Great post! 😃 Cypress is my favorite testing tool as it makes writing tests fun! It's a very satisfying feeling to see the tests happening live with cypress open.

Just a question: in the last part, are you installing Cypress during the Netlify build? I tried it once last year and it was not so good: Netlify took a long time to unzip Cypress and wouldn't cache it afterward.
Have you checked out the Cypress Netlify Build Plugin? It can also prevent a deploy if the tests are failing and it caches Cypress properly between builds.

However, my favorite approach is to run the Cypress tests in the GitHub Action, but against a branch deploy on Netlify! This is as close as we can get to the production environment and "bad" code cannot be committed to the production branch.

I posted about it here:

Collapse
 
debs_obrien profile image
Debbie O'Brien

Thanks I just modified article as yes the Netlify plugin is really nice. Interesting approach to test it on the preview branch. How do you then check your tests are ok? wait on email if it fails or ??

Collapse
 
mornir profile image
Jérôme Pott • Edited
  • I protected the master branch so that branches with GitHub Action that failed cannot be merged.
  • I can check the test details in the GitHub Action, but the best way is to connect the GitHub repository to the Cypress dashboard. There I can see screenshots and videos of the test runs.
  • There's also a GitHub Integration for Cypress that enriches the pull requests with nicely presented information.
  • I also receive emails in case tests are failings.

Here's an example of such a pull request: github.com/mornir/copywork-portfol...