False positive - S2699 - Add at least one assertion to this test case - with repro

  • ALM used : Azure DevOps
  • CI system used : Azure DevOps
  • Languages of the repository : typescript
  • Error observed : False positive - S2699 - Add at least one assertion to this test case
  • Steps to reproduce :
    GitHub - HugoMercierYuc/sonar-jest-sinon

This is a default NX repository for Angular with Jest, when you import sinon in your unit test file, you get the false-positive Sonar issue.

  1. open src/app/app.component.spec.ts
  2. the 3 unit tests raising a Sonar issue S2699
  3. if you remove the third test and remove the line import { spy } from ‘sinon’;
    => the Sonar issue S2699 is not raised anymore

new ticket after my first one was closed : False positive - S2699 - Add at least one assertion to this test case

Thanks for your help
Hugo

1 Like

hello,
Any update on that ?
Thanks a lot for your help
Hugo

Hello again, Hugo!

Thank you for providing this feedback, I have opened an issue on SonarJS.

Best,
Ilia