Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Istanbul provider returns 0% coverage until code changes #554

Closed
4 tasks done
ericchernuka opened this issue Dec 13, 2024 · 1 comment
Closed
4 tasks done

Istanbul provider returns 0% coverage until code changes #554

ericchernuka opened this issue Dec 13, 2024 · 1 comment

Comments

@ericchernuka
Copy link

ericchernuka commented Dec 13, 2024

Describe the bug

Recently, I've found the Istanbul provider inconsistent in its reporting. In my attached reproduction and video, you can see that upon launching the project and pressing "run all with coverage," I got a report of 0%. Clicking an individual test with coverage removes coverage entirely from the vscode test explorer.

Adding additional code seems to alter the behaviour, as shown when I add another function and press "run all with coverage" again. This results in realistic coverage again, and the UI shows accurate hover details.

I couldn't garner much from the logs, but let me know what you think.

Kapture.2024-12-12.at.23.27.30.mp4

Reproduction

https://github.com/ericchernuka/vitest-test-extension-istanbul-repro

Output

##
## First run from run all with coverage
##
[INFO 11:28:06 PM] [Worker] Running coverage with configuration: {
  provider: 'istanbul',
  enabled: true,
  all: true,
  clean: true,
  cleanOnRerun: true,
  reportsDirectory: '/var/folders/w6/rvbn81tx2x5gl02kqsx854hh0000gn/T/vitest-coverage-a38def18-5ca2-4f77-8c89-154f6084ca54',
  exclude: [
    'coverage/**',
    'dist/**',
    '**/node_modules/**',
    '**/[.]**',
    'packages/*/test?(s)/**',
    '**/*.d.ts',
    '**/virtual:*',
    '**/__x00__*',
    '**/\x00*',
    'cypress/**',
    'test?(s)/**',
    'test?(-*).?(c|m)[jt]s?(x)',
    '**/*{.,-}{test,spec,bench,benchmark}?(-d).?(c|m)[jt]s?(x)',
    '**/__tests__/**',
    '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*',
    '**/vitest.{workspace,projects}.[jt]s?(on)',
    '**/.{eslint,mocha,prettier}rc.{?(c|m)js,yml}'
  ],
  reportOnFailure: true,
  reporter: [ [ 'json', [Object] ] ],
  extension: [
    '.js',     '.cjs',
    '.mjs',    '.ts',
    '.mts',    '.tsx',
    '.jsx',    '.vue',
    '.svelte', '.marko',
    '.astro'
  ],
  allowExternal: false,
  excludeAfterRemap: false,
  ignoreEmptyLines: true,
  processingConcurrency: 10,
  thresholds: undefined
}
[INFO 11:28:06 PM] Running all tests in vitest-test
[INFO 11:28:06 PM] [Worker] 2024-12-13T06:28:06.536Z vitest:coverage Uncovered file /Users/ec/Code/vitest-test/src/sum.ts 0/1
[INFO 11:28:06 PM] [Worker] 2024-12-13T06:28:06.536Z vite:load 0.18ms [fs] src/sum.ts?v=1734071286536
[INFO 11:28:06 PM] [Worker] 2024-12-13T06:28:06.545Z vite:import-analysis 0.14ms [no imports] src/sum.ts?v=1734071286536
[INFO 11:28:06 PM] [Worker] 2024-12-13T06:28:06.546Z vite:transform 9.14ms src/sum.ts?v=1734071286536
[INFO 11:28:06 PM] [Worker] Waiting for the coverage report to generate: /var/folders/w6/rvbn81tx2x5gl02kqsx854hh0000gn/T/vitest-coverage-a38def18-5ca2-4f77-8c89-154f6084ca54
Coverage reports retrieved: /var/folders/w6/rvbn81tx2x5gl02kqsx854hh0000gn/T/vitest-coverage-a38def18-5ca2-4f77-8c89-154f6084ca54
[INFO 11:28:06 PM] Removed coverage reports /var/folders/w6/rvbn81tx2x5gl02kqsx854hh0000gn/T/vitest-coverage-a38def18-5ca2-4f77-8c89-154f6084ca54

##
## 2nd run from individual test
##
[INFO 11:29:32 PM] [Worker] Running coverage with configuration: {
  provider: 'istanbul',
  enabled: true,
  all: true,
  clean: true,
  cleanOnRerun: true,
  reportsDirectory: '/var/folders/w6/rvbn81tx2x5gl02kqsx854hh0000gn/T/vitest-coverage-11c7b729-e4f4-40a8-a69c-81348c77bf05',
  exclude: [
    'coverage/**',
    'dist/**',
    '**/node_modules/**',
    '**/[.]**',
    'packages/*/test?(s)/**',
    '**/*.d.ts',
    '**/virtual:*',
    '**/__x00__*',
    '**/\x00*',
    'cypress/**',
    'test?(s)/**',
    'test?(-*).?(c|m)[jt]s?(x)',
    '**/*{.,-}{test,spec,bench,benchmark}?(-d).?(c|m)[jt]s?(x)',
    '**/__tests__/**',
    '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*',
    '**/vitest.{workspace,projects}.[jt]s?(on)',
    '**/.{eslint,mocha,prettier}rc.{?(c|m)js,yml}'
  ],
  reportOnFailure: true,
  reporter: [ [ 'json', [Object] ] ],
  extension: [
    '.js',     '.cjs',
    '.mjs',    '.ts',
    '.mts',    '.tsx',
    '.jsx',    '.vue',
    '.svelte', '.marko',
    '.astro'
  ],
  allowExternal: false,
  excludeAfterRemap: false,
  ignoreEmptyLines: true,
  processingConcurrency: 10,
  thresholds: undefined
}
[INFO 11:29:32 PM] Running 1 file(s) with name pattern: ^\s?adds 1 \+ 2 to equal 3$
[INFO 11:29:32 PM] [Worker] Waiting for the coverage report to generate: /var/folders/w6/rvbn81tx2x5gl02kqsx854hh0000gn/T/vitest-coverage-11c7b729-e4f4-40a8-a69c-81348c77bf05
[INFO 11:29:32 PM] [Worker] Coverage reports retrieved: /var/folders/w6/rvbn81tx2x5gl02kqsx854hh0000gn/T/vitest-coverage-11c7b729-e4f4-40a8-a69c-81348c77bf05
[INFO 11:29:32 PM] Removed coverage reports /var/folders/w6/rvbn81tx2x5gl02kqsx854hh0000gn/T/vitest-coverage-11c7b729-e4f4-40a8-a69c-81348c77bf05

##
## 3rd run after adding additional code (sum2) and pressing run all with coverage
##
[INFO 11:30:02 PM] [Worker] Running coverage with configuration: {
  provider: 'istanbul',
  enabled: true,
  all: true,
  clean: true,
  cleanOnRerun: true,
  reportsDirectory: '/var/folders/w6/rvbn81tx2x5gl02kqsx854hh0000gn/T/vitest-coverage-e53f96d3-199b-44c0-8ae1-c5cc25ed4e24',
  exclude: [
    'coverage/**',
    'dist/**',
    '**/node_modules/**',
    '**/[.]**',
    'packages/*/test?(s)/**',
    '**/*.d.ts',
    '**/virtual:*',
    '**/__x00__*',
    '**/\x00*',
    'cypress/**',
    'test?(s)/**',
    'test?(-*).?(c|m)[jt]s?(x)',
    '**/*{.,-}{test,spec,bench,benchmark}?(-d).?(c|m)[jt]s?(x)',
    '**/__tests__/**',
    '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*',
    '**/vitest.{workspace,projects}.[jt]s?(on)',
    '**/.{eslint,mocha,prettier}rc.{?(c|m)js,yml}'
  ],
  reportOnFailure: true,
  reporter: [ [ 'json', [Object] ] ],
  extension: [
    '.js',     '.cjs',
    '.mjs',    '.ts',
    '.mts',    '.tsx',
    '.jsx',    '.vue',
    '.svelte', '.marko',
    '.astro'
  ],
  allowExternal: false,
  excludeAfterRemap: false,
  ignoreEmptyLines: true,
  processingConcurrency: 10,
  thresholds: undefined
}
[INFO 11:30:02 PM] Running all tests in vitest-test
[INFO 11:30:02 PM] [Worker] 2024-12-13T06:30:02.835Z vite:cache [memory-hmr] src/sum.test.ts
[INFO 11:30:02 PM] [Worker] 2024-12-13T06:30:02.836Z vite:load 0.19ms [fs] /src/sum.ts
[INFO 11:30:02 PM] [Worker] 2024-12-13T06:30:02.845Z vite:import-analysis 0.04ms [no imports] src/sum.ts
[INFO 11:30:02 PM] [Worker] 2024-12-13T06:30:02.845Z vite:transform 8.53ms /src/sum.ts
[INFO 11:30:02 PM] [Worker] 2024-12-13T06:30:02.860Z vitest:coverage Covered files 1/1
[INFO 11:30:02 PM] [Worker] Waiting for the coverage report to generate: /var/folders/w6/rvbn81tx2x5gl02kqsx854hh0000gn/T/vitest-coverage-e53f96d3-199b-44c0-8ae1-c5cc25ed4e24
[INFO 11:30:02 PM] [Worker] Coverage reports retrieved: /var/folders/w6/rvbn81tx2x5gl02kqsx854hh0000gn/T/vitest-coverage-e53f96d3-199b-44c0-8ae1-c5cc25ed4e24
[INFO 11:30:02 PM] Removed coverage reports /var/folders/w6/rvbn81tx2x5gl02kqsx854hh0000gn/T/vitest-coverage-e53f96d3-199b-44c0-8ae1-c5cc25ed4e24

Extension Version

1.8.3

Vitest Version

2.1.8

Validations

@sheremet-va
Copy link
Member

Fixed by #560

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants