fix: re-export CDP Session directly from playwright (#8702)

This commit is contained in:
Bill Collins 2025-10-13 13:08:22 +01:00 committed by GitHub
parent 91c7e5f926
commit 9553ab9234
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 4 additions and 24 deletions

View File

@ -60,7 +60,6 @@
},
"devDependencies": {
"playwright": "^1.55.0",
"playwright-core": "^1.55.0",
"vitest": "workspace:*"
}
}

View File

@ -14,7 +14,6 @@ const external = [
...Object.keys(pkg.peerDependencies || {}),
/^@?vitest(\/|$)/,
'vite',
'playwright-core/types/protocol',
]
const dtsUtils = createDtsUtils()

View File

@ -10,8 +10,8 @@ import type {
FrameLocator,
LaunchOptions,
Page,
CDPSession as PlaywrightCDPSession,
} from 'playwright'
import type { Protocol } from 'playwright-core/types/protocol'
import type { SourceMap } from 'rollup'
import type { ResolvedConfig } from 'vite'
import type {
@ -570,6 +570,8 @@ type PWScreenshotOptions = NonNullable<Parameters<Page['screenshot']>[0]>
type PWSelectOptions = NonNullable<Parameters<Page['selectOption']>[2]>
type PWDragAndDropOptions = NonNullable<Parameters<Page['dragAndDrop']>[2]>
type PWSetInputFiles = NonNullable<Parameters<Page['setInputFiles']>[2]>
// Must be re-aliased here or rollup-plugin-dts removes the import alias and you end up with a circular reference
type PWCDPSession = PlaywrightCDPSession
declare module 'vitest/browser' {
export interface UserEventHoverOptions extends PWHoverOptions {}
@ -585,22 +587,5 @@ declare module 'vitest/browser' {
mask?: ReadonlyArray<Element | Locator> | undefined
}
export interface CDPSession {
send<T extends keyof Protocol.CommandParameters>(
method: T,
params?: Protocol.CommandParameters[T]
): Promise<Protocol.CommandReturnValues[T]>
on<T extends keyof Protocol.Events>(
event: T,
listener: (payload: Protocol.Events[T]) => void
): this
once<T extends keyof Protocol.Events>(
event: T,
listener: (payload: Protocol.Events[T]) => void
): this
off<T extends keyof Protocol.Events>(
event: T,
listener: (payload: Protocol.Events[T]) => void
): this
}
export interface CDPSession extends PWCDPSession {}
}

3
pnpm-lock.yaml generated
View File

@ -512,9 +512,6 @@ importers:
playwright:
specifier: ^1.55.0
version: 1.55.0
playwright-core:
specifier: ^1.55.0
version: 1.55.0
vitest:
specifier: workspace:*
version: link:../vitest