Answers to questions like 'how to grab tests from multile folders' and to questions 'how to avoid file can't be indexed twice' are just opposite each other. So this question is not a duplicate of one of them.
I have a structure like that:
src
|_component1
| |__tests__
| |_units.tsx
|
|_component2
|__tests__
|_units.tsx
If I try customize sonar
like this:
'sonar.sources': 'src',
'sonar.tests': 'src',
'sonar.exclusions': 'src/**/__tests__/**/*',
'sonar.tests.inclusions': 'src/**/__tests__/**/*.{js,jsx,ts,tsx}',
It fails with error file can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files
.
If I provide sonar.sources
and sonar.tests
with different paths, it can't see my multiple __tests__
directories.
How could I combine both grab multiple test directories and avoid this error?
Okey, I've got an answer!
Proper settings are:
'sonar.sources': 'src',
'sonar.tests': 'src',
'sonar.exclusions': '**/__tests__/**',
'sonar.test.inclusions': '**/__tests__/**',
It's not sonar.TESTS.inclusions
, it's sonar.TEST.inclusions
, 1 letter difference.