,

Level 1 Exercise on Flaky Tests with Cypress

Posted by

Cypress Flaky Test Exercise: Level 1

The Importance of Flaky Test Exercise in Cypress

Flaky tests can be a recurring nightmare for developers, causing frustration and wasting valuable time. In Cypress, a flaky test is a test that fails intermittently due to non-deterministic behavior or timing issues. These tests can be a major roadblock in the continuous integration and delivery process, as they lead to unreliable test results and can delay the release of software.

Level 1 Flaky Test Exercise

As part of the Cypress Flaky Test Exercise: Level 1, developers are tasked with identifying and fixing flaky tests in their test suite. This exercise helps developers build a deeper understanding of the Cypress testing framework and improve the stability of their tests.

Steps to Complete the Exercise:

  1. Identify flaky tests in your test suite by running your tests multiple times.
  2. Debug the flaky tests to understand the root cause of the failures.
  3. Implement fixes to make the tests more stable and reliable.
  4. Rerun the tests to ensure that the fixes have resolved the flakiness.

Benefits of Completing the Exercise:

  • Improved test stability: By fixing flaky tests, developers can trust the test results and ensure that failures are actual bugs rather than temporary issues.
  • Faster test execution: Stable tests allow for quicker feedback on the code changes, leading to faster development cycles.
  • Enhanced developer skills: The exercise challenges developers to think critically about their test implementation and improve their problem-solving skills.

Completing the Cypress Flaky Test Exercise: Level 1 is an essential step in mastering the Cypress testing framework and building robust test suites. By addressing flaky tests early on, developers can create a solid foundation for their test automation efforts and ensure the reliability of their application.

0 0 votes
Article Rating
5 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@easonkai9195
7 months ago

Hi, gleb, so thanks for teaching about flaky tests.

Flaky tests often exist in real-world projects.

It is very difficult to debug a flaky case.

in this level 1 example

I wonder how you knew the root cause was not enough wait?

How to find out or debug at first?

so thanks

@danr4826
7 months ago

While debugging the flaky test I added an assertion that the button shows the value "Saving" `cy.get('input[value="Saving…"]').should('be.visible')` and then that it doesn't exist. But it was still failing, then I added assertion for each input field to check for the expected value, although I didn't really think this would fix the flake.
Then I gave up and added a timeout 😁
`// the "Saving" message should not exist

cy.get('input[value="Saving…"]', { timeout: 10000 }).should('not.exist')`
I guess I was on the right track, I was also thinking of intercepting the loading spinner but it just seemed I was overcomplicating things, not sure if I would be worth intercepting and aliasing the loading spinner request 🤷🏽
Love the excercises! Thanks 👏🏽

@terminal3553
7 months ago

Love this type of videos!

@vaniamocherniuk4894
7 months ago

Thank you for your content 😉

@akash1699
7 months ago

Hi sir,
Can you show me how to do parallel run for free for the cucumber feature files