@vitest/browser 2.0.0-beta.11 → 2.0.0-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/matchers.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ import type jsdomMatchers from './jest-dom.js'
2
+ import type { Assertion } from 'vitest'
3
+
4
+ declare module 'vitest' {
5
+ interface JestAssertion<T = any> extends jsdomMatchers.default.TestingLibraryMatchers<void, T> {}
6
+
7
+ type Promisify<O> = {
8
+ [K in keyof O]: O[K] extends (...args: infer A) => infer R
9
+ ? O extends R
10
+ ? Promisify<O[K]>
11
+ : (...args: A) => Promise<R>
12
+ : O[K];
13
+ }
14
+
15
+ type PromisifyDomAssertion<T> = Promisify<Assertion<T>>
16
+
17
+ interface ExpectStatic {
18
+ element: <T extends Element>(element: T, options?: ExpectPollOptions) => PromisifyDomAssertion<Awaited<T>>
19
+ }
20
+ }
21
+
22
+ export {}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/browser",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.11",
4
+ "version": "2.0.0-beta.12",
5
5
  "description": "Browser running for Vitest",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -28,6 +28,9 @@
28
28
  "types": "./context.d.ts",
29
29
  "default": "./context.js"
30
30
  },
31
+ "./matchers": {
32
+ "types": "./matchers.d.ts"
33
+ },
31
34
  "./providers/webdriverio": {
32
35
  "types": "./providers/webdriverio.d.ts"
33
36
  },
@@ -48,7 +51,7 @@
48
51
  "peerDependencies": {
49
52
  "playwright": "*",
50
53
  "webdriverio": "*",
51
- "vitest": "2.0.0-beta.11"
54
+ "vitest": "2.0.0-beta.12"
52
55
  },
53
56
  "peerDependenciesMeta": {
54
57
  "playwright": {
@@ -68,9 +71,10 @@
68
71
  "msw": "^2.3.1",
69
72
  "sirv": "^2.0.4",
70
73
  "ws": "^8.17.1",
71
- "@vitest/utils": "2.0.0-beta.11"
74
+ "@vitest/utils": "2.0.0-beta.12"
72
75
  },
73
76
  "devDependencies": {
77
+ "@testing-library/jest-dom": "^6.4.6",
74
78
  "@types/ws": "^8.5.10",
75
79
  "@wdio/protocols": "^8.38.0",
76
80
  "birpc": "0.2.17",
@@ -81,10 +85,10 @@
81
85
  "playwright-core": "^1.44.1",
82
86
  "safaridriver": "^0.1.2",
83
87
  "webdriverio": "^8.38.2",
84
- "@vitest/ws-client": "2.0.0-beta.11",
85
- "@vitest/runner": "2.0.0-beta.11",
86
- "vitest": "2.0.0-beta.11",
87
- "@vitest/ui": "2.0.0-beta.11"
88
+ "@vitest/runner": "2.0.0-beta.12",
89
+ "@vitest/ui": "2.0.0-beta.12",
90
+ "@vitest/ws-client": "2.0.0-beta.12",
91
+ "vitest": "2.0.0-beta.12"
88
92
  },
89
93
  "scripts": {
90
94
  "build": "rimraf dist && pnpm build:node && pnpm build:client",
@@ -2,9 +2,13 @@ import type {
2
2
  BrowserContext,
3
3
  BrowserContextOptions,
4
4
  Frame,
5
+ FrameLocator,
5
6
  LaunchOptions,
6
7
  Page,
8
+ CDPSession
7
9
  } from 'playwright'
10
+ import { Protocol } from 'playwright-core/types/protocol'
11
+ import '../matchers.js'
8
12
 
9
13
  declare module 'vitest/node' {
10
14
  interface BrowserProviderOptions {
@@ -17,7 +21,8 @@ declare module 'vitest/node' {
17
21
 
18
22
  export interface BrowserCommandContext {
19
23
  page: Page
20
- frame: Frame
24
+ frame(): Promise<Frame>
25
+ iframe: FrameLocator
21
26
  context: BrowserContext
22
27
  }
23
28
  }
@@ -39,4 +44,23 @@ declare module '@vitest/browser/context' {
39
44
  export interface UserEventDragOptions extends UserEventDragAndDropOptions {}
40
45
 
41
46
  export interface ScreenshotOptions extends PWScreenshotOptions {}
47
+
48
+ export interface CDPSession {
49
+ send<T extends keyof Protocol.CommandParameters>(
50
+ method: T,
51
+ params?: Protocol.CommandParameters[T]
52
+ ): Promise<Protocol.CommandReturnValues[T]>
53
+ on<T extends keyof Protocol.Events>(
54
+ event: T,
55
+ listener: (payload: Protocol.Events[T]) => void
56
+ ): this;
57
+ once<T extends keyof Protocol.Events>(
58
+ event: T,
59
+ listener: (payload: Protocol.Events[T]) => void
60
+ ): this;
61
+ off<T extends keyof Protocol.Events>(
62
+ event: T,
63
+ listener: (payload: Protocol.Events[T]) => void
64
+ ): this;
65
+ }
42
66
  }
@@ -1,4 +1,5 @@
1
1
  import type { RemoteOptions } from 'webdriverio'
2
+ import '../matchers.js'
2
3
 
3
4
  declare module 'vitest/node' {
4
5
  interface BrowserProviderOptions extends RemoteOptions {}