Skip to content

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

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

Activity

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Fields

Priority

None yet

Effort

None yet

Target date

None yet

Start date

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions