You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guide/browser/assertion-api.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,18 +7,18 @@ title: Assertion API | Browser Mode
7
7
Vitest provides a wide range of DOM assertions out of the box forked from [`@testing-library/jest-dom`](https://github.com/testing-library/jest-dom) library with the added support for locators and built-in retry-ability.
8
8
9
9
::: tip TypeScript Support
10
-
If you are using [TypeScript](/guide/browser/#typescript) or want to have correct type hints in `expect`, make sure you have `@vitest/browser/context` referenced somewhere. If you never imported from there, you can add a `reference` comment in any file that's covered by your `tsconfig.json`:
10
+
If you are using [TypeScript](/guide/browser/#typescript) or want to have correct type hints in `expect`, make sure you have `vitest/browser` referenced somewhere. If you never imported from there, you can add a `reference` comment in any file that's covered by your `tsconfig.json`:
11
11
12
12
```ts
13
-
/// <referencetypes="@vitest/browser/context" />
13
+
/// <referencetypes="vitest/browser" />
14
14
```
15
15
:::
16
16
17
17
Tests in the browser might fail inconsistently due to their asynchronous nature. Because of this, it is important to have a way to guarantee that assertions succeed even if the condition is delayed (by a timeout, network request, or animation, for example). For this purpose, Vitest provides retriable assertions out of the box via the [`expect.poll`](/api/expect#poll) and `expect.element` APIs:
Vitest exposes access to raw Chrome Devtools Protocol via the `cdp` method exported from `@vitest/browser/context`. It is mostly useful to library authors to build tools on top of it.
41
+
Vitest exposes access to raw Chrome Devtools Protocol via the `cdp` method exported from `vitest/browser`. It is mostly useful to library authors to build tools on top of it.
42
42
43
43
```ts
44
-
import { cdp } from'@vitest/browser/context'
44
+
import { cdp } from'vitest/browser'
45
45
46
46
const input =document.createElement('input')
47
47
document.body.appendChild(input)
@@ -97,10 +97,10 @@ export default function BrowserCommands(): Plugin {
97
97
}
98
98
```
99
99
100
-
Then you can call it inside your test by importing it from `@vitest/browser/context`:
100
+
Then you can call it inside your test by importing it from `vitest/browser`:
101
101
102
102
```ts
103
-
import { commands } from'@vitest/browser/context'
103
+
import { commands } from'vitest/browser'
104
104
import { expect, test } from'vitest'
105
105
106
106
test('custom command works correctly', async () => {
Defines multiple browser setups. Every config has to have at least a `browser` field.
56
53
57
-
In addition to that, you can also specify most of the [project options](/config/) (not marked with a <NonProjectOption /> icon) and some of the `browser` options like `browser.testerHtmlPath`.
54
+
You can specify most of the [project options](/config/) (not marked with a <NonProjectOption /> icon) and some of the `browser` options like `browser.testerHtmlPath`.
58
55
59
56
::: warning
60
57
Every browser config inherits options from the root config:
@@ -79,8 +76,6 @@ export default defineConfig({
79
76
})
80
77
```
81
78
82
-
During development, Vitest supports only one [non-headless](#browser-headless) configuration. You can limit the headed project yourself by specifying `headless: false` in the config, or by providing the `--browser.headless=false` flag, or by filtering projects with `--project=chromium` flag.
83
-
84
79
For more examples, refer to the ["Multiple Setups" guide](/guide/browser/multiple-setups).
85
80
:::
86
81
@@ -94,8 +89,6 @@ List of available `browser` options:
By default, Vitest creates an array with a single element which uses the [`browser.name`](#browser-name) field as a `browser`. Note that this behaviour will be removed with Vitest 4.
98
-
99
92
Under the hood, Vitest transforms these instances into separate [test projects](/advanced/api/test-project) sharing a single Vite server for better caching performance.
100
93
101
94
## browser.headless
@@ -134,12 +127,12 @@ Configure options for Vite server that serves code in the browser. Does not affe
134
127
-**Default:**`'preview'`
135
128
-**CLI:**`--browser.provider=playwright`
136
129
137
-
The return value of the provider factory. You can import the factory from `@vitest/browser/providers/<provider-name>` or make your own provider:
130
+
The return value of the provider factory. You can import the factory from `@vitest/browser-<provider-name>` or make your own provider:
138
131
139
132
```ts{8-10}
140
-
import { playwright } from '@vitest/browser/providers/playwright'
141
-
import { webdriverio } from '@vitest/browser/providers/webdriverio'
142
-
import { preview } from '@vitest/browser/providers/preview'
133
+
import { playwright } from '@vitest/browser-playwright'
134
+
import { webdriverio } from '@vitest/browser-webdriverio'
135
+
import { preview } from '@vitest/browser-preview'
143
136
144
137
export default defineConfig({
145
138
test: {
@@ -155,7 +148,7 @@ export default defineConfig({
155
148
To configure how provider initializes the browser, you can pass down options to the factory function:
156
149
157
150
```ts{7-13,20-26}
158
-
import { playwright } from '@vitest/browser/providers/playwright'
151
+
import { playwright } from '@vitest/browser-playwright'
Copy file name to clipboardExpand all lines: docs/guide/browser/context.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ title: Context API | Browser Mode
4
4
5
5
# Context API
6
6
7
-
Vitest exposes a context module via `@vitest/browser/context` entry point. As of 2.0, it exposes a small set of utilities that might be useful to you in tests.
7
+
Vitest exposes a context module via `vitest/browser` entry point. As of 2.0, it exposes a small set of utilities that might be useful to you in tests.
Vitest exposes a [Context API](/guide/browser/context) with a small set of utilities that might be useful to you in tests. For example, if you need to make an interaction, like clicking an element or typing text into an input, you can use `userEvent` from `@vitest/browser/context`. Read more at the [Interactivity API](/guide/browser/interactivity-api).
415
+
Vitest exposes a [Context API](/guide/browser/context) with a small set of utilities that might be useful to you in tests. For example, if you need to make an interaction, like clicking an element or typing text into an input, you can use `userEvent` from `vitest/browser`. Read more at the [Interactivity API](/guide/browser/interactivity-api).
@@ -532,7 +532,7 @@ For unsupported frameworks, we recommend using `testing-library` packages:
532
532
You can also see more examples in [`browser-examples`](https://github.com/vitest-tests/browser-examples) repository.
533
533
534
534
::: warning
535
-
`testing-library` provides a package `@testing-library/user-event`. We do not recommend using it directly because it simulates events instead of actually triggering them - instead, use [`userEvent`](/guide/browser/interactivity-api) imported from `@vitest/browser/context` that uses Chrome DevTools Protocol or Webdriver (depending on the provider) under the hood.
535
+
`testing-library` provides a package `@testing-library/user-event`. We do not recommend using it directly because it simulates events instead of actually triggering them - instead, use [`userEvent`](/guide/browser/interactivity-api) imported from `vitest/browser` that uses Chrome DevTools Protocol or Webdriver (depending on the provider) under the hood.
0 commit comments