Expect.poll is not recognized as assertion in tests

Make sure to read this post before raising a thread here:

Then tell us:

  • What language is this for? JavaScript
  • Which rule? S2699
  • Why do you believe it’s a false-positive/false-negative? This rule does not include expect.poll which is a valid assertion but the linter reports error.
  • Are you using
    • SonarQube Cloud? No
    • SonarQube Server / Community Build - which version? No
    • SonarQube for IDE - which IDE/version? No
      • in connected mode with SonarQube Server / Community Build or SonarQube Cloud?
  • How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)

Just add this code to your project

import { expect, test } from 'vitest'

test('element exists', async () => {
  await expect.poll(() => document.querySelector('.element')).toBeTruthy()
})

and then run ESLint with eslint-plugin-sonarjs plugin

Hi @Mikilll,

Thank you for reporting this issue and for helping us improving this rule!

I was able to reproduce the false positive using the code snippet you provided.
A ticket JS-2089 has been created to track this issue.

The fix is already implemented and will be included in the next SonarJS release.

Thank you again for your report.
Erwan