All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.javascript.rules.javascript.S5973.html Maven / Gradle / Ivy

There is a newer version: 5.0.0.6962
Show newest version

Why is this an issue?

Unstable / flaky tests are tests which sometimes pass and sometimes fail, without any code change. Obviously, they slow down developments when developers have to rerun failed tests. However, the real problem is that you can’t completely trust these tests, they might fail for many different reasons and you don’t know if any of them will happen in production.

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

jest.retryTimes(3); // Noncompliant

describe('API.foo()', function() {
  it('should return 5 when computing ...', function() {
    doSomethingUnstable();
  });
});

Resources

Documentation

Articles & blog posts





© 2015 - 2025 Weber Informatics LLC | Privacy Policy