Sonarlint false positive for test file with fast-check tests

If your question is about SonarLint in the IntelliJ Platform, VS Code, Visual Studio, or Eclipse, please post it in that sub-category.

Otherwise, please provide:

  • Operating system: linux mint
  • IDE name and flavor/env: webstorm

And a thorough description of the problem / question:

I’m using sonarlint on a typescript project.
I have a test file for some utility functions that contain only property tests (using the GitHub - dubzzz/fast-check: Property based testing framework for JavaScript (like QuickCheck) written in TypeScript library, more specifically the @fast-check/vitest package):

describe('toISODate', () => {
  test.prop([fc.date()])('should match expected format', (date) =>
    /^[+-]?\d+-\d{2}-\d{2}$/.test(toDateISOString(date)),
  );

  test.prop([fc.date()])('should return a parseable date', (date) => !Number.isNaN(Date.parse(toDateISOString(date))));

  test.prop([fc.date()])('should be parsed as input date without time', (date) => {
    const withoutTime = new Date(date);
    withoutTime.setUTCHours(0);
    withoutTime.setUTCMinutes(0);
    withoutTime.setUTCSeconds(0);
    withoutTime.setUTCMilliseconds(0);
    const parsed = new Date(Date.parse(toDateISOString(date)));

    return parsed.getTime() === withoutTime.getTime();
  });
});
// and other similar describe blocks…

Sonarlint incorrectly raises the “Test files should contain at least one test case” error.

Hello Alain,

Thank you for bringing up this issue. We have opened a ticket for it which you can follow here: [JS-187] - Jira