Skip to content

Sometimes incorrectly shown inline coverage for nested functions #563

Open
@motz-art

Description

@motz-art

Describe the bug

In some specific cases (e.g. see the repo) inline coverage is shown incorrectly.

Reproduction

Run the test from the repo: https://github.com/motz-art/vscode-vitest-incorrect-coverage-issue.git
Expected:
Lines 13 -19 shown as covered with green background (both gutter where line number is shown as well as inline code coverage).
Actual:
Lines 13-19: shown as partially covered orange.
image

Output

[INFO 11:26:56 PM] [Worker] Running coverage with configuration: {
  provider: 'v8',
  enabled: true,
  all: true,
  clean: true,
  cleanOnRerun: true,
  reportsDirectory: 'C:/Users/Oleg/AppData/Local/Temp/vitest-coverage-035070af-a0bc-4e7c-8505-c48d0acbf7c0',
  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: 16,
  thresholds: undefined

[11:26:56 PM] Initiating deferred test run
[INFO 11:26:56 PM] Running all tests in vscode-vitest-incorect-coverage-issue
[11:26:56 PM] The runner is starting because tests index.spec.js were started due to a file change
[11:26:56 PM] Enqueuing "undefined"
[11:26:56 PM] Enqueuing "x"
[11:26:56 PM] No task result for "index.spec.js", ignoring
[11:26:56 PM] Enqueuing "undefined" because it was just collected
[11:26:56 PM] Enqueuing "x" because it was just collected
[11:26:56 PM] No errors found for "index.spec.js"
[11:26:56 PM] Marking "undefined" as passed
[11:26:56 PM] Marking "x" as passed
[INFO 11:26:56 PM] [Worker] Waiting for the coverage report to generate: C:/Users/Oleg/AppData/Local/Temp/vitest-coverage-035070af-a0bc-4e7c-8505-c48d0acbf7c
[INFO 11:26:56 PM] [Worker] Coverage reports retrieved: C:/Users/Oleg/AppData/Local/Temp/vitest-coverage-035070af-a0bc-4e7c-8505-c48d0acbf7c
[11:26:56 PM] Ending test run index.spec.js
[11:26:56 PM] Coverage was disabled due to all requests being exhausted
[INFO 11:26:56 PM] Removed coverage reports C:/Users/Oleg/AppData/Local/Temp/vitest-coverage-035070af-a0bc-4e7c-8505-c48d0acbf7c0
[11:26:56 PM] [VSCODE] Ignoring file: node_modules\.vite\vitest\results.json

Extension Version

1.8.5

Vitest Version

2.1.8

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions