Skip to content

provider.getCDPSession types not augmented #9688

@AriPerkkio

Description

@AriPerkkio

Describe the bug

The '@vitest/browser-playwright' is augmenting client side types for CDP properly. However server side CDP types are not augmented.

import { playwright } from '@vitest/browser-playwright'
import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    browser: {
      commands: {
        async interceptFetch(ctx) {
          const session = await ctx.provider.getCDPSession(ctx.sessionId)

          session.on('Fetch.requestPaused', async (event) => {
            const url = event.request.url
            //             ❌ ^^^^^^^ Property 'request' does not exist on type 'unknown'  
          })
        },
      },
    },
  },
})

Client side works correctly:

import { cdp } from "vitest/browser";

const session = cdp();
session.on("Fetch.requestPaused", async (event) => {
  const url = event.request.url;
  //             ✅ ^^^^^^^ (property) request: Protocol.Network.Request, The details of the request.
});

Reproduction

In Vitest monorepo:

System Info

Vitest monorepo, `main`

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: browserIssues and PRs related to the browser runnertypes

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions