Flaky test are those that are marked as pass on one test run but fail on another. Test can become flaky if one element is loaded before another. For an instance, I had 20 e2e test written that always passes when running locally but showed flaky test when executed via github actions.
Cypress provides multiple ways in which we can handle flaky test. In this post I will discuss two of the best ways.
Retry-ability
Within the cypress test framework we can use the retries parameter, as shown below this parameter is set within the Cypress.config.js, if a test fails this parameter will execute the test again based on the given count to see if the test will pass. In my personal view this approach has helped to overcome the flaky test that I was faced with.
As shown below, the config will retry a failed test only when the test are executed on background using the cy run command.
Comments
Post a Comment