Hi i have a single module with this structure:
- src/
- index.ts ← only exports
-
- lib/
-
-
- index.ts ← only exports
-
-
-
- services/
-
-
-
-
- test
-
-
-
-
-
-
- index.ts ← test file
-
-
-
-
-
-
- index.ts ← only with development
-
-
only the service/index.ts
file has code and it has unit test on the test folder.
I am using vitest and when running test localy it shows the coverage:
The lcov file generated report:
TN:
SF:src/lib/services/index.ts
FN:5,getPartners
FN:9,get
FNF:2
FNH:2
FNDA:1,getPartners
FNDA:1,get
DA:1,1
DA:2,1
DA:3,1
DA:4,1
DA:5,1
DA:6,1
DA:7,1
DA:8,1
DA:9,1
LF:9
LH:9
BRDA:5,0,0,1
BRDA:9,1,0,1
BRF:2
BRH:2
end_of_record
When using lcov viewer (https://lcov-viewer.netlify.app/)
it matches the coverage from the terminal.
I had src/index.ts and src/lib/index.ts on exclusion property on the coverage prop on vitest.
But on sonar platform it only shows the src/lib/index.ts as new code and also sonar requires to add coverate to
export * from
The project is correct configured for typescript and start to present this behavior on 20/03 whithout ani change on our sonar project or in our sonar config inside the project folder.
my vitest config:
import { fileURLToPath, URL } from 'node:url'
import { createVuePlugin as vue } from 'vite-plugin-vue2'
import { configDefaults, defineConfig } from 'vitest/config'
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
},
test: {
passWithNoTests: true,
exclude: [
...configDefaults.exclude,
'packages/template/*',
'*.{config,options}.*',
'**/*model*',
],
environment: 'jsdom',
globals: true,
coverage: {
provider: 'c8',
all: true,
reporter: ['json', 'lcov', 'text', 'text-summary', 'html'],
exclude: [
'*.{config,options}.*',
'coverage/**',
'**/*.spec.*',
'.nuxt/**',
'dist/**',
'.*.{js|ts}',
'configure-webpack.js',
'**/*.d.*',
'**/*/enums/*',
'**/*model*',
'**/*model*',
'src/index.ts',
'src/lib/index.ts',
],
reportsDirectory:
'../../../../coverage/libs/customer',
},
deps: {
external: ['**/node_modules/**', '**/dist/**'],
},
include: ['**/*.spec.{js,ts,vue}'],
},
})