@vitest/browser 3.1.3 → 3.2.0-beta.2

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/context.d.ts CHANGED
@@ -29,12 +29,19 @@ export interface ScreenshotOptions {
29
29
  element?: Element | Locator
30
30
  /**
31
31
  * Path relative to the current test file.
32
+ * @default `__screenshots__/${testFileName}/${testName}.png`
32
33
  */
33
34
  path?: string
34
35
  /**
35
36
  * Will also return the base64 encoded screenshot alongside the path.
36
37
  */
37
38
  base64?: boolean
39
+ /**
40
+ * Keep the screenshot on the file system. If file is not saved,
41
+ * `page.screenshot` always returns `base64` screenshot.
42
+ * @default true
43
+ */
44
+ save?: boolean
38
45
  }
39
46
 
40
47
  export interface BrowserCommands {
@@ -552,11 +559,16 @@ export interface BrowserPage extends LocatorSelectors {
552
559
  * Make a screenshot of the test iframe or a specific element.
553
560
  * @returns Path to the screenshot file or path and base64.
554
561
  */
562
+ screenshot(options: Omit<ScreenshotOptions, 'save'> & { save: false }): Promise<string>
555
563
  screenshot(options: Omit<ScreenshotOptions, 'base64'> & { base64: true }): Promise<{
556
564
  path: string
557
565
  base64: string
558
566
  }>
559
- screenshot(options?: ScreenshotOptions): Promise<string>
567
+ screenshot(options?: Omit<ScreenshotOptions, 'base64'>): Promise<string>
568
+ screenshot(options?: ScreenshotOptions): Promise<string | {
569
+ path: string
570
+ base64: string
571
+ }>
560
572
  /**
561
573
  * Extend default `page` object with custom methods.
562
574
  */
@@ -568,5 +580,14 @@ export interface BrowserPage extends LocatorSelectors {
568
580
  elementLocator(element: Element): Locator
569
581
  }
570
582
 
583
+ export interface BrowserLocators {
584
+ createElementLocators(element: Element): LocatorSelectors
585
+ extend(methods: {
586
+ [K in keyof LocatorSelectors]?: (...args: Parameters<LocatorSelectors[K]>) => ReturnType<LocatorSelectors[K]> | string
587
+ }): void
588
+ }
589
+
590
+ export const locators: BrowserLocators
591
+
571
592
  export const page: BrowserPage
572
593
  export const cdp: () => CDPSession
package/context.js CHANGED
@@ -6,6 +6,7 @@ export const server = null
6
6
  export const userEvent = null
7
7
  export const cdp = null
8
8
  export const commands = null
9
+ export const locators = null
9
10
 
10
11
  const pool = globalThis.__vitest_worker__?.ctx?.pool
11
12
 
@@ -13,7 +13,7 @@
13
13
  ]
14
14
  },
15
15
  "tester/tester.html": {
16
- "file": "__vitest_browser__/tester-D8qCxA_3.js",
16
+ "file": "__vitest_browser__/tester-CrBz0KXk.js",
17
17
  "name": "tester",
18
18
  "src": "tester/tester.html",
19
19
  "isEntry": true,