TypeScript's tagged template literal syntax tests not visible

SonarQube Server:

  • Enterprise Edition
  • v2025.1 (102418)
    SonarQube for IDE:
  • 11.3.0.82551 (same behavior in 10.* version)

If tagged template literal syntax is used for jest test and it’s only test in file than both SonarQube and SonarQube IDE shows error

Add some tests to this file or delete it.
Test files should contain at least one test casetypescript:S2187 

Example of test which triggers error

import { TextUtils } from './text.utils.js';

describe('TextUtils', () => {
    describe('doSomething', () => {
        it.each`
            text          | expected
            ${'00003000'} | ${'3000'}
            ${'00003030'} | ${'3030'}
        `('it should do something: $text', ({ text, expected }) => {
            const result = TextUtils.doSomething(text);
            expect(result).toStrictEqual(expected);
        });
    });

After changing syntax to array error disappears

import { TextUtils } from './text.utils.js';

describe('TextUtils', () => {
    describe('doSomething', () => {
        test.each([
            ['00003000', '3000'],
        ])('it should do something: $text', (text, expected) => {
            const result = TextUtils.doSomething(text);
            expect(result).toStrictEqual(expected);
        });
    });
});

Hello @kjonski,

thanks for reporting this. We are aware of this and already have an Jira ticket to handle this case.

Cheers

Hello Victor,
Thank you for information and looking forward for resolution.

Cheers

Just created a PR with the fix. You can expect the fix to be deployed in the next couple of weeks

Great news! Have a great weekend!

1 Like