Skip to content

vite-plus/test/browser-playwright types import playwright, which vite-plus does not declare, so provider options go unchecked under pnpm #2854

Description

@cmaciasjimenez

What happens

vite-plus/dist/test/browser-playwright.d.ts imports types from playwright:

import { Page, Frame, FrameLocator, BrowserContext, CDPSession, Browser, LaunchOptions, ConnectOptions, BrowserContextOptions } from 'playwright';

vite-plus doesn't declare playwright as a dependency or a peer. It only declares @vitest/browser-playwright as an optional peer. With pnpm's isolated layouts (confirmed with virtualStoreType: global), vite-plus's own slot therefore has no playwright, and TypeScript can't resolve the import. With skipLibCheck: true (the usual setting), the Playwright types in the provider's declarations silently lose their meaning:

  • playwright({ contextOptions }) is unchecked, so contextOptions: { reducedMotion: "bogus" } compiles;
  • cdp().send(...), typed through the CDPSession augmentation, is error-typed, so type-aware Oxlint reports no-unsafe-call on every call.

Repro

  1. A pnpm project with virtualStoreType: global and vite-plus@1.0.0, playwright@1.63.0 and @vitest/browser-playwright@5.0.1 as devDependencies.
  2. In vite.config.ts: provider: playwright({ contextOptions: { reducedMotion: "bogus" } }) from vite-plus/test/browser-playwright.
  3. vp check passes.
  4. ls vite-plus's slot (<store>/links/@/vite-plus/1.0.0/<hash>/node_modules/): vitest, vite, oxlint… but no playwright.

Proposal

Declare playwright as an optional peer of vite-plus, the way @vitest/browser-playwright already is:

"peerDependencies": { "playwright": "*" },
"peerDependenciesMeta": { "playwright": { "optional": true } }

Workaround: a .pnpmfile.mjs readPackage hook that adds that optional peer to vite-plus. With it, playwright is linked into vite-plus's slot, and vp check rejects reducedMotion: "bogus" with TS2322: Type '"bogus"' is not assignable to type '"no-preference" | "reduce" | null | undefined'.

Versions: vite-plus 1.0.0, pnpm 12.8.1, playwright 1.63.0, TypeScript 7.0.2, macOS.

Activity

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

Metadata

Metadata

Assignees

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