We log the Jasmine test fails into a text file with a custom reporter. Afterwards we rerun the failed tests again only. If these still fail we report these fails at failures to research.
jasmine.getEnv().addReporter({
specDone: async (result) => {
if (result.status === 'failed') {
fs.appendFileSync(SeleniumBrowser.getFailedTestsFile(), `${result.description}\n`);
}
await this.quit();
},
});
We use a script to rerun the tests from the command line. We are using jest -T
, but with Jasmine I think you can use command-line arguments like --specs='tests/**/*.js' --grep="TestNameFromFile"
I once read an article (which I can't find anymore) that the a re-run strategy of three was the perfect number. Sometimes your infrastructure or network just hangs. After three times you are sure it is the test that is failing.
I would record the flakiness of these tests though and schedule a flakiness research once in awhile, but you do not want developers to waste adhoc time to re-run or research once in a couple of run errors. Some flaky test do succeed when run alone, these are the tests you do want to fix, but random single incidents should be ignored. keep in mind it could be race-conditions so do check them, but not instant adhoc :)
protractor-flake
is an option, yes. But, ideally, we are thinking if there is a way to retry a selenium command instead of a full test. Thanks.