Every feature test case starts with landing page testing in cypress.
We are witnessing failures here because of network connectivity issues.
it('should load home page', () => {
cy.waitUntil(() =>
cy.contains('Home', { timeout: 500000 }).should('exist')
);
});
So, is there a way to reload this test case if it fails once or twice and avoid recursion?
I suspect retries will work here, if so how can we configure it?
CodePudding user response:
You can use Test Retries. You can add it to Test Suite Level, Test Case level or globally as well. The test will be re-triggered in case of failures.
runMode
works for headless. openMode
for test runner. You can add both of them followed by how many times you want to retry them. So 2
means, once after the test failed, the test will be re-executed 2 times until the test passes, So if the test passes in the first re-execution, the second re-execution will not happen.
it(
'should load home page',
{
retries: {
runMode: 2,
openMode: 1,
},
},
() => {
cy.waitUntil(() => cy.contains('Home', {timeout: 500000}).should('exist'))
}
)