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);
});
});
});