@vitest/browser 4.0.0-beta.13 → 4.0.0-beta.14
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 +50 -9
- package/context.js +3 -2
- package/dist/client/.vite/manifest.json +2 -2
- package/dist/client/__vitest__/assets/{index-C15NF4dG.js → index-CKAjAT2u.js} +1 -1
- package/dist/client/__vitest__/index.html +1 -1
- package/dist/client/__vitest_browser__/{orchestrator-Pdu7HCGX.js → orchestrator-Ce7D5fGP.js} +8 -6
- package/dist/client/__vitest_browser__/{tester-DYNLfPFH.js → tester-Vm4ppAv-.js} +4 -1
- package/dist/client/orchestrator.html +1 -1
- package/dist/client/tester/tester.html +1 -1
- package/dist/client.js +1 -1
- package/dist/context.js +70 -12
- package/dist/expect-element.js +1 -1
- package/dist/{public-utils-B6exS8fl.js → index-BnLTaCRv.js} +3 -3
- package/dist/index.d.ts +36 -172
- package/dist/index.js +515 -1487
- package/dist/{locators/index.d.ts → locators.d.ts} +25 -2
- package/dist/locators.js +1 -0
- package/jest-dom.d.ts +5 -5
- package/matchers.d.ts +1 -1
- package/package.json +11 -33
- package/utils.d.ts +5 -5
- package/dist/index-BPDFwkoW.js +0 -1
- package/dist/index-CwoiDq7G.js +0 -6
- package/dist/locators/index.js +0 -1
- package/dist/locators/playwright.js +0 -1
- package/dist/locators/preview.js +0 -1
- package/dist/locators/webdriverio.js +0 -1
- package/dist/providers/playwright.d.ts +0 -105
- package/dist/providers/playwright.js +0 -385
- package/dist/providers/preview.d.ts +0 -16
- package/dist/providers/preview.js +0 -44
- package/dist/providers/webdriverio.d.ts +0 -51
- package/dist/providers/webdriverio.js +0 -206
- package/dist/utils.js +0 -1
- package/providers.d.ts +0 -7
package/context.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SerializedConfig } from 'vitest'
|
|
2
|
+
import { StringifyOptions } from 'vitest/internal/browser'
|
|
2
3
|
import { ARIARole } from './aria-role.js'
|
|
3
4
|
import {} from './matchers.js'
|
|
4
5
|
|
|
@@ -186,7 +187,7 @@ export interface UserEvent {
|
|
|
186
187
|
* state of keyboard to press and release buttons correctly.
|
|
187
188
|
*
|
|
188
189
|
* **Note:** Unlike `@testing-library/user-event`, the default `userEvent` instance
|
|
189
|
-
* from
|
|
190
|
+
* from `vitest/browser` is created once, not every time its methods are called!
|
|
190
191
|
* @see {@link https://vitest.dev/guide/browser/interactivity-api.html#userevent-setup}
|
|
191
192
|
*/
|
|
192
193
|
setup: () => UserEvent
|
|
@@ -361,6 +362,10 @@ export interface LocatorOptions {
|
|
|
361
362
|
* regular expression. Note that exact match still trims whitespace.
|
|
362
363
|
*/
|
|
363
364
|
exact?: boolean
|
|
365
|
+
hasText?: string | RegExp
|
|
366
|
+
hasNotText?: string | RegExp
|
|
367
|
+
has?: Locator
|
|
368
|
+
hasNot?: Locator
|
|
364
369
|
}
|
|
365
370
|
|
|
366
371
|
export interface LocatorByRoleOptions extends LocatorOptions {
|
|
@@ -660,13 +665,6 @@ export const server: {
|
|
|
660
665
|
config: SerializedConfig
|
|
661
666
|
}
|
|
662
667
|
|
|
663
|
-
export interface LocatorOptions {
|
|
664
|
-
hasText?: string | RegExp
|
|
665
|
-
hasNotText?: string | RegExp
|
|
666
|
-
has?: Locator
|
|
667
|
-
hasNot?: Locator
|
|
668
|
-
}
|
|
669
|
-
|
|
670
668
|
/**
|
|
671
669
|
* Handler for user interactions. The support is provided by the browser provider (`playwright` or `webdriverio`).
|
|
672
670
|
* If used with `preview` provider, fallbacks to simulated events via `@testing-library/user-event`.
|
|
@@ -732,11 +730,54 @@ export interface BrowserPage extends LocatorSelectors {
|
|
|
732
730
|
|
|
733
731
|
export interface BrowserLocators {
|
|
734
732
|
createElementLocators(element: Element): LocatorSelectors
|
|
733
|
+
// TODO: enhance docs
|
|
734
|
+
/**
|
|
735
|
+
* Extends `page.*` and `locator.*` interfaces.
|
|
736
|
+
* @see {@link}
|
|
737
|
+
*
|
|
738
|
+
* @example
|
|
739
|
+
* ```ts
|
|
740
|
+
* import { locators } from 'vitest/browser'
|
|
741
|
+
*
|
|
742
|
+
* declare module 'vitest/browser' {
|
|
743
|
+
* interface LocatorSelectors {
|
|
744
|
+
* getByCSS(css: string): Locator
|
|
745
|
+
* }
|
|
746
|
+
* }
|
|
747
|
+
*
|
|
748
|
+
* locators.extend({
|
|
749
|
+
* getByCSS(css: string) {
|
|
750
|
+
* return `css=${css}`
|
|
751
|
+
* }
|
|
752
|
+
* })
|
|
753
|
+
* ```
|
|
754
|
+
*/
|
|
735
755
|
extend(methods: {
|
|
736
|
-
[K in keyof LocatorSelectors]?: (
|
|
756
|
+
[K in keyof LocatorSelectors]?: (
|
|
757
|
+
this: BrowserPage | Locator,
|
|
758
|
+
...args: Parameters<LocatorSelectors[K]>
|
|
759
|
+
) => ReturnType<LocatorSelectors[K]> | string
|
|
737
760
|
}): void
|
|
738
761
|
}
|
|
739
762
|
|
|
763
|
+
|
|
764
|
+
export type PrettyDOMOptions = Omit<StringifyOptions, 'maxLength'>
|
|
765
|
+
|
|
766
|
+
export const utils: {
|
|
767
|
+
getElementLocatorSelectors(element: Element): LocatorSelectors
|
|
768
|
+
debug(
|
|
769
|
+
el?: Element | Locator | null | (Element | Locator)[],
|
|
770
|
+
maxLength?: number,
|
|
771
|
+
options?: PrettyDOMOptions,
|
|
772
|
+
): void
|
|
773
|
+
prettyDOM(
|
|
774
|
+
dom?: Element | Locator | undefined | null,
|
|
775
|
+
maxLength?: number,
|
|
776
|
+
prettyFormatOptions?: PrettyDOMOptions,
|
|
777
|
+
): string
|
|
778
|
+
getElementError(selector: string, container?: Element): Error
|
|
779
|
+
}
|
|
780
|
+
|
|
740
781
|
export const locators: BrowserLocators
|
|
741
782
|
|
|
742
783
|
export const page: BrowserPage
|
package/context.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vitest resolves "
|
|
1
|
+
// Vitest resolves "vitest/browser" as a virtual module instead
|
|
2
2
|
|
|
3
3
|
// fake exports for static analysis
|
|
4
4
|
export const page = null
|
|
@@ -7,12 +7,13 @@ export const userEvent = null
|
|
|
7
7
|
export const cdp = null
|
|
8
8
|
export const commands = null
|
|
9
9
|
export const locators = null
|
|
10
|
+
export const utils = null
|
|
10
11
|
|
|
11
12
|
const pool = globalThis.__vitest_worker__?.ctx?.pool
|
|
12
13
|
|
|
13
14
|
throw new Error(
|
|
14
15
|
// eslint-disable-next-line prefer-template
|
|
15
|
-
'
|
|
16
|
+
'vitest/browser can be imported only inside the Browser Mode. '
|
|
16
17
|
+ (pool
|
|
17
18
|
? `Your test is running in ${pool} pool. Make sure your regular tests are excluded from the "test.include" glob pattern.`
|
|
18
19
|
: 'Instead, it was imported outside of Vitest.'),
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"name": "utils"
|
|
5
5
|
},
|
|
6
6
|
"orchestrator.html": {
|
|
7
|
-
"file": "__vitest_browser__/orchestrator-
|
|
7
|
+
"file": "__vitest_browser__/orchestrator-Ce7D5fGP.js",
|
|
8
8
|
"name": "orchestrator",
|
|
9
9
|
"src": "orchestrator.html",
|
|
10
10
|
"isEntry": true,
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
]
|
|
14
14
|
},
|
|
15
15
|
"tester/tester.html": {
|
|
16
|
-
"file": "__vitest_browser__/tester-
|
|
16
|
+
"file": "__vitest_browser__/tester-Vm4ppAv-.js",
|
|
17
17
|
"name": "tester",
|
|
18
18
|
"src": "tester/tester.html",
|
|
19
19
|
"isEntry": true,
|