2023-11-29 14:42:05 +01:00

38 lines
1.2 KiB
Plaintext

== Why is this an issue?
include::../common/why.adoc[]
Some tools, such as Jest, enable developers to automatically retry flaky tests. This might be acceptable as a temporary solution, but it should eventually be fixed. The more flaky tests you add, the more chances there are for a bug to arrive in production.
This rule raises an issue when these functions are called with a value higher than ``++0++``:
* ``++jest.retry()++``
* ``++this.retries()++`` inside a Mocha test case
== How to fix it
Make your test stable so that it passes on the first try, or remove it.
=== Code examples
==== Noncompliant code example
[source,js]
----
jest.retryTimes(3); // Noncompliant
describe('API.foo()', function() {
it('should return 5 when computing ...', function() {
doSomethingUnstable();
});
});
----
== Resources
=== Documentation
* Jest docs - https://jestjs.io/docs/jest-object#jestretrytimesnumretries-options[jest.retryTimes()]
* Mocha docs - https://mochajs.org/#retry-tests[Retry tests]
=== Articles & blog posts
* Spotify Engineering - https://engineering.atspotify.com/2019/11/18/test-flakiness-methods-for-identifying-and-dealing-with-flaky-tests/[Test Flakiness - Methods for identifying and dealing with flaky tests]