The Flaky Test Challenge
There are several flaky situations. Each example is in its own branch and includes changes to the application source code and the testing code. Can you solve each one by fixing the test code only? Try fixing the spec before watching the video that shows my solution.
- branch level1 to warm you up. Solution video
- branch level2 where you need to burn the test to prove it is flaky or not. Solution video
- branch level3 shows a fast test that somehow still fails. Solution video
- branch level4 has a situation where the app "loses" a few first entered letters. Solution video
- branch level5 has the app "losing" an element we are trying to click. Solution video
- branch level6 has the app loading slowly which causes random failures. Solution video
- branch level7 shows the flake when saving the data is too slow. Solution video
- branch level8 has an iframe we need to wait for. Solution video
- branch level9 deals with a random popup on visit. Solution video
📝 Read the blog post Cypress Flaky Tests Exercises
If you like practicing Cypress test writing and want more hands-on exercises, check out my Cypres courses. Also 📝 read the blog post Flaky IFrame Online Store Test.
- clone this repo to your local machine
- check out a branch with the flaky test
git checkout level1
,git checkout level2
, etc - run
npm install
to install all dependencies - start the app in one terminal with
npm start
. You should see:
Compiled successfully!
The app is running at:
http://localhost:3000/
Note that the development build is not optimized.
To create a production build, use npm run build.
- open Cypress test runner with
npx cypress open
command. Click on the app.cy.js spec to run it.
Did the spec pass?
The original application code forked from dangi13/flaky-test-cypress.
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com> © 2024
- @bahmutov
- glebbahmutov.com
- blog
- videos
- presentations
- cypress.tips
- Cypress Tips & Tricks Newsletter
- my Cypress courses
License: MIT - do anything with the code, but don't blame me if it does not work.
Support: if you find any problems with this module, email / tweet / open issue on Github