I have created Cypress Network Testing Course with 90+ test exercises for anyone who wants to learn cy.intercept, cy.request, and other Cypress commands. The starting exercise specs are in the repo bahmutov/fastify-example-tests. Each exercise is a test to be filled out by the user, something like this:
1 | it('shows the fruit returned by the server', () => { |
Each lesson has a video showing how I implement the above starting code until it really does what the comments say. To make sure all answers are correct I have another repository with answers to each lesson. That repo bahmutov/fastify-example-answers is private, of course. I don't want everyone to just look at the answer and say "Yeah, this is how I would write this test". How do I know the answers are correct, especially as I upgrade Cypress version?
I run them against the application using cypress run
, of course! The test application lives in the repo bahmutov/fastify-example, luckily it is easy to check out both repos using GitHub Actions. Here is my workflow file from fastify-example-answers
repo that checks out both repos, installs the app's dependencies, starts the application in the background, and runs all Cypress tests.
1 | name: ci |
Every time I push a commit to fastify-example-answers
, it is tested by the CI. The current status is shown in the README badge.
Bonus: the Cypress version badge is created by my own little utility dependency-version-badge. Here is the GitHub Actions workflow that periodically updates it and pushes the changed README.md file if needed.
1 | name: badges |
Read the blog post Keep Examples Up To Date to learn more about dependencies and version badges.