Skip to content

vite-plus/test module identities break vitest type augmentations #1256

@joknoll

Description

@joknoll

Describe the bug

When using Vite+ test imports, third-party Vitest type augmentations do not apply because the module specifiers differ from vitest and vitest/browser.

I have a small demo repo as a reproduction. In this repo I get type errors for the test/repro.browser.test.ts file.

Reproduction

https://github.com/joknoll/vite-plus-vitest-type-aug

Steps to reproduce

Running vp check results in these errors:

  × typescript(TS2339): Property 'render' does not exist on type 'BrowserPage'.
   ╭─[tests/browser/repro.browser.test.ts:7:29]
 6 │ test("reproduces missing Vite+ type augmentations", async () => {
 7 │   const screen = await page.render(Repro, { label: "hello" });
   ·                             ──────
 8 │
   ╰────

  × typescript(TS2339): Property 'element' does not exist on type 'ExpectStatic'.
    ╭─[tests/browser/repro.browser.test.ts:9:16]
  8 │
  9 │   await expect.element(screen.getByRole("heading", { name: "hello" })).toBeVisible();
    ·                ───────
 10 │ });
    ╰────

System Info

Environment:
  Version  24.14.1
  Source   lts

Tool Paths:
  node  /home/hannes/.vite-plus/js_runtime/node/24.14.1/bin/node
  npm   /home/hannes/.vite-plus/js_runtime/node/24.14.1/bin/npm
  npx   /home/hannes/.vite-plus/js_runtime/node/24.14.1/bin/npx

Used Package Manager

pnpm

Logs

Validations

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions