@vitest/browser 2.0.0-beta.9 → 2.0.0

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.9",
4
+ "version": "2.0.0",
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
  },
@@ -41,13 +44,14 @@
41
44
  "types": "./dist/index.d.ts",
42
45
  "files": [
43
46
  "*.d.ts",
47
+ "context.js",
44
48
  "dist",
45
49
  "providers"
46
50
  ],
47
51
  "peerDependencies": {
48
52
  "playwright": "*",
49
53
  "webdriverio": "*",
50
- "vitest": "2.0.0-beta.9"
54
+ "vitest": "2.0.0"
51
55
  },
52
56
  "peerDependenciesMeta": {
53
57
  "playwright": {
@@ -61,26 +65,30 @@
61
65
  }
62
66
  },
63
67
  "dependencies": {
64
- "@testing-library/dom": "^9.3.3",
68
+ "@testing-library/dom": "^10.2.0",
65
69
  "@testing-library/user-event": "^14.5.2",
66
70
  "magic-string": "^0.30.10",
71
+ "msw": "^2.3.1",
67
72
  "sirv": "^2.0.4",
68
- "@vitest/utils": "2.0.0-beta.9"
73
+ "ws": "^8.17.1",
74
+ "@vitest/utils": "2.0.0"
69
75
  },
70
76
  "devDependencies": {
77
+ "@testing-library/jest-dom": "^6.4.6",
71
78
  "@types/ws": "^8.5.10",
72
- "@wdio/protocols": "^8.32.0",
79
+ "@wdio/protocols": "^8.38.0",
73
80
  "birpc": "0.2.17",
74
81
  "flatted": "^3.3.1",
82
+ "pathe": "^1.1.2",
75
83
  "periscopic": "^4.0.2",
76
- "playwright": "^1.44.0",
77
- "playwright-core": "^1.44.0",
84
+ "playwright": "^1.45.0",
85
+ "playwright-core": "^1.45.0",
78
86
  "safaridriver": "^0.1.2",
79
- "webdriverio": "^8.36.1",
80
- "@vitest/runner": "2.0.0-beta.9",
81
- "@vitest/ui": "2.0.0-beta.9",
82
- "vitest": "2.0.0-beta.9",
83
- "@vitest/ws-client": "2.0.0-beta.9"
87
+ "webdriverio": "^8.39.0",
88
+ "@vitest/ws-client": "2.0.0",
89
+ "@vitest/runner": "2.0.0",
90
+ "@vitest/ui": "2.0.0",
91
+ "vitest": "2.0.0"
84
92
  },
85
93
  "scripts": {
86
94
  "build": "rimraf dist && pnpm build:node && pnpm build:client",
@@ -1,8 +1,66 @@
1
- import type { Browser, LaunchOptions } from 'playwright'
1
+ import type {
2
+ BrowserContext,
3
+ BrowserContextOptions,
4
+ Frame,
5
+ FrameLocator,
6
+ LaunchOptions,
7
+ Page,
8
+ CDPSession
9
+ } from 'playwright'
10
+ import { Protocol } from 'playwright-core/types/protocol'
11
+ import '../matchers.js'
2
12
 
3
13
  declare module 'vitest/node' {
4
14
  interface BrowserProviderOptions {
5
15
  launch?: LaunchOptions
6
- page?: Parameters<Browser['newPage']>[0]
16
+ context?: Omit<
17
+ BrowserContextOptions,
18
+ 'ignoreHTTPSErrors' | 'serviceWorkers'
19
+ >
20
+ }
21
+
22
+ export interface BrowserCommandContext {
23
+ page: Page
24
+ frame(): Promise<Frame>
25
+ iframe: FrameLocator
26
+ context: BrowserContext
27
+ }
28
+ }
29
+
30
+ type PWHoverOptions = Parameters<Page['hover']>[1]
31
+ type PWClickOptions = Parameters<Page['click']>[1]
32
+ type PWDoubleClickOptions = Parameters<Page['dblclick']>[1]
33
+ type PWFillOptions = Parameters<Page['fill']>[2]
34
+ type PWScreenshotOptions = Parameters<Page['screenshot']>[0]
35
+ type PWSelectOptions = Parameters<Page['selectOption']>[2]
36
+ type PWDragAndDropOptions = Parameters<Page['dragAndDrop']>[2]
37
+
38
+ declare module '@vitest/browser/context' {
39
+ export interface UserEventHoverOptions extends PWHoverOptions {}
40
+ export interface UserEventClickOptions extends PWClickOptions {}
41
+ export interface UserEventDoubleClickOptions extends PWDoubleClickOptions {}
42
+ export interface UserEventFillOptions extends PWFillOptions {}
43
+ export interface UserEventSelectOptions extends PWSelectOptions {}
44
+ export interface UserEventDragOptions extends UserEventDragAndDropOptions {}
45
+
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;
7
65
  }
8
66
  }
@@ -1,5 +1,10 @@
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 {}
6
+
7
+ export interface BrowserCommandContext {
8
+ browser: WebdriverIO.Browser
9
+ }
5
10
  }