Skip to content

Test failure squiggles don't appear on Windows (drive letter path mismatch) #795

Description

@afrasso

On Windows, when a test fails and vitest.applyDiagnostic is enabled, the extension does not show a squiggly underline on the failing line in the editor.

The test still shows as failed in the Testing panel, and the failure overlay appears when you click it. But there is no inline diagnostic squiggle, and the failure often does not show up in the Problems panel either.

In the Vitest output channel, the extension logs something like:

Could not find a valid stack for <test name> [...]
[DECOR] Reset all decorations

The stack trace in that log looks correct (it has the right file path and line number). The extension just fails to match it to the test file.

I plan to submit a PR with a fix.

Expected behavior

When a test fails on Windows, I expect a red squiggle on the failing line (usually the expect(...) line), the same way it works on macOS/Linux and the same way TypeScript/ESLint errors show squiggles.

Reproduction

  1. Use Windows with the Vitest extension installed.
  2. Open any project with Vitest tests.
  3. Make sure "vitest.applyDiagnostic": true is set (this is the default).
  4. Run a test from the Testing panel (beaker icon), not from the terminal.
  5. Use a test that fails on purpose, e.g. change expect(x).toBe(1) to expect(x).toBe(2).

Result: Test shows as failed, but no squiggle on the failing line.

Root cause: In parseLocationFromStacks (packages/extension/src/runner.ts), the stack file path is normalized with normalizeDriveLetter() (e.g. C:\...), but testItem.uri.fsPath is compared as-is. On Windows, VS Code uses a lowercase drive letter (c:\...). The strict === comparison fails even though both paths point to the same file.

Workaround: Patching the installed extension so parseLocationFromStacks also runs normalizeDriveLetter() on testItem.uri.fsPath makes squiggles appear after reload.

Output

Could not find a valid stack for should return 1 [
  {
    "method": "",
    "file": "C:/git/my-project/__tests__/example.test.ts",
    "line": 28,
    "column": 20
  }
]
[DECOR] Reset all decorations

Extension Version

1.50.6

Vitest Version

Any recent version (tested with Vitest 3.x)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions