Tests using not operator incorrectly identified as not including assertions

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

Then tell us:

  • Typescript
  • typescript:S2699 - Tests should include assertions
  • Some of our tests have been identified as not containing assertions. They do contain assertions but the use of the not operator makes them appear as invalid. It seems the rule only gets highlighted on test files which happen to import from ‘supertest’, which aligns with the rule description.
  • SonarQube Cloud
import request from 'supertest';

describe('app', () => {
  it('does no console logs', async () => {
    jest.spyOn(global.console, 'log');

    await request(app).get('/');

    expect(console.log).not.toHaveBeenCalled();
  });
});

Hey there.

Thanks for the report!

There’s a rather broad ticket here (JS-627) that I think covers what you’ve pointed out is missing here. In any case I’ve linked this thread to that ticket.