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
Run Vitest tests in a browser. If the browser name is not specified, Vitest will try to determine your default browser automatically. We use [WebdriverIO](https://webdriver.io/) for running tests by default, but it can be configured with [browser.provider](/config/#browser-provider) option.
1004
+
Run Vitest tests in a browser. We use [WebdriverIO](https://webdriver.io/) for running tests by default, but it can be configured with [browser.provider](/config/#browser-provider) option.
1005
1005
1006
1006
::: tip NOTE
1007
1007
Read more about testing in a real browser in the [guide page](/guide/browser).
@@ -1022,11 +1022,13 @@ Run all tests inside a browser by default. Can be overriden with [`poolMatchGlob
1022
1022
#### browser.name
1023
1023
1024
1024
-**Type:**`string`
1025
-
-**Default:**_tries to find default browser automatically_
1026
1025
-**CLI:**`--browser=safari`
1027
1026
1028
-
Run all tests in a specific browser. If not specified, tries to find a browser automatically.
1027
+
Run all tests in a specific browser. Possible options in different providers:
Path to a provider that will be used when running browser tests. Provider should be exported using `default` export and have this shape:
1055
+
Path to a provider that will be used when running browser tests. Vitest provides two providers which are `webdriverio` (default) and `playwright`. Custom providers should be exported using `default` export and have this shape:
Copy file name to clipboardExpand all lines: docs/guide/browser.md
+13-19Lines changed: 13 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,32 +14,26 @@ To activate browser mode in your Vitest configuration, you can use the `--browse
14
14
exportdefaultdefineConfig({
15
15
test: {
16
16
browser: {
17
-
enabled: true
17
+
enabled: true,
18
+
name: 'chrome', // browser name is required
18
19
},
19
20
}
20
21
})
21
22
```
22
23
23
24
## Browser Option Types:
24
25
25
-
The browser option in Vitest can be set to either a boolean or a string type. If set to `true`, Vitest will try to automatically find your default browser. You can also specify a browser by providing its name as a `string`. The available browser options are:
26
-
-`firefox`
27
-
-`chrome`
28
-
-`edge`
29
-
-`safari`
30
-
31
-
Here's an example configuration setting chrome as the browser option:
26
+
The browser option in Vitest depends on the provider. Vitest will fail, if you pass `--browser` and don't specify its name in the config file. Available options:
When using the Safari browser option, the `safaridriver` needs to be activated by running `sudo safaridriver --enable` on your device.
55
+
When using the Safari browser option with WebdriverIO, the `safaridriver` needs to be activated by running `sudo safaridriver --enable` on your device.
62
56
63
57
Additionally, when running your tests, Vitest will attempt to install some drivers for compatibility with `safaridriver`.
0 commit comments