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

Inline Coverage from vitest is not shown #556

Closed
4 tasks done
motz-art opened this issue Dec 16, 2024 · 1 comment · Fixed by #557
Closed
4 tasks done

Inline Coverage from vitest is not shown #556

motz-art opened this issue Dec 16, 2024 · 1 comment · Fixed by #557

Comments

@motz-art
Copy link

motz-art commented Dec 16, 2024

Describe the bug

When I run the test in the repo, I do not see inline coverage in the editor. And in the Window output I see an error:
[error] Error loading coverage details Illegal argument: character must be non-negative.

Reproduction

  1. Run the test from the repo https://github.com/motz-art/vscode-vitest-coverage-issue.git.
    Expected:
    Inline code coverage is shown in the editor.
    Actual:
    Only high level coverage info is shown but inline coverage info (code lines are not highlighted) is missing.
    At the same time Window output shows one error:
    Error loading coverage details Illegal argument: character must be non-negative

image

Note: When I change the test to call process(1); instead, then inline code coverage is shown properly:
image

Output

[INFO 1:12:46 PM] [v1.8.3] Vitest extension is activated because Vitest is installed or there is a Vite/Vitest config file in the workspace.
[INFO 1:12:47 PM] [API] Running Vitest v2.1.8 (vitest-coverage-issue/vitest.config.js) with [email protected]: C:\Program Files\nodejs\node.EXE 
[INFO 1:12:48 PM] [Worker] �[33mThe CJS build of Vite's Node API is deprecated. See https://vite.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.�[39
[INFO 1:12:48 PM] [API] Vitest v2.1.8 (vitest-coverage-issue/vitest.config.js) child process 75792 created
[INFO 1:12:48 PM] [API] Watching C:/git/TMP/vitest-coverage-issue/vitest.config.js
[INFO 1:12:48 PM] [VSCODE] Watching vitest-coverage-issue with pattern **/*
[INFO 1:12:48 PM] [API] Collecting tests: index.spec.js
[1:12:48 PM] Not starting the runner because tests are being collected for index.spec.js
[1:12:48 PM] [VSCODE] Ignoring file: index.spec.js.git
[1:12:48 PM] [VSCODE] Ignoring file: index.js.git
[1:12:48 PM] There is no test run for "index.spec.js"
[1:12:48 PM] No test run to finish for index.spec.js
[1:12:48 PM] [VSCODE] Ignoring file: node_modules\.vite\vitest\results.json
[1:12:58 PM] [VSCODE] Ignoring file: .git\FETCH_HEAD
[1:12:58 PM] [VSCODE] Ignoring file: .git\FETCH_HEAD
[1:12:59 PM] [VSCODE] Ignoring file: index.spec.js.git
[1:12:59 PM] [VSCODE] Ignoring file: index.js.git
[INFO 1:13:02 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-bb25e8a0-148e-43b7-b79a-49b79408bd62',
  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

[1:13:02 PM] Initiating deferred test run
[INFO 1:13:02 PM] Running all tests in vitest-coverage-issue
[1:13:02 PM] The runner is starting because tests index.spec.js were started due to a file change
[1:13:02 PM] Enqueuing "should show coverage"
[1:13:02 PM] No task result for "index.spec.js", ignoring
[1:13:02 PM] Enqueuing "should show coverage" because it was just collected
[1:13:02 PM] No errors found for "index.spec.js"
[1:13:02 PM] Marking "should show coverage" as passed
[INFO 1:13:02 PM] [Worker] Waiting for the coverage report to generate: C:/Users/Oleg/AppData/Local/Temp/vitest-coverage-bb25e8a0-148e-43b7-b79a-49b79408bd6
[INFO 1:13:02 PM] [Worker] Coverage reports retrieved: C:/Users/Oleg/AppData/Local/Temp/vitest-coverage-bb25e8a0-148e-43b7-b79a-49b79408bd6
[1:13:02 PM] Ending test run index.spec.js
[1:13:02 PM] Coverage was disabled due to all requests being exhausted
[INFO 1:13:02 PM] Removed coverage reports C:/Users/Oleg/AppData/Local/Temp/vitest-coverage-bb25e8a0-148e-43b7-b79a-49b79408bd62
[1:13:02 PM] [VSCODE] Ignoring file: node_modules\.vite\vitest\results.json
[1:13:08 PM] [VSCODE] Ignoring file: .git\FETCH_HEAD
[1:13:08 PM] [VSCODE] Ignoring file: .git\FETCH_HEAD
[1:13:09 PM] [VSCODE] Ignoring file: index.spec.js.git
[1:13:09 PM] [VSCODE] Ignoring file: index.js.git

Extension Version

1.8.3

Vitest Version

2.1.8

Validations

@motz-art
Copy link
Author

@sheremet-va Vladimir, thank you very much for your support!

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

Successfully merging a pull request may close this issue.

1 participant