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
In this case, Vitest will run in headless mode using the Chrome browser.
121
121
122
+
## Context <Version>2.0.0</Version> {#context}
123
+
124
+
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.
125
+
126
+
```ts
127
+
exportconst server: {
128
+
/**
129
+
* Platform the Vitest server is running on.
130
+
* The same as calling `process.platform` on the server.
131
+
*/
132
+
platform:Platform
133
+
/**
134
+
* Runtime version of the Vitest server.
135
+
* The same as calling `process.version` on the server.
Command is a function that invokes another function on the server and passes down the result back to the browser. Vitest exposes several built-in commands you can use in your browser tests.
163
+
164
+
## Built-in Commands
165
+
166
+
### Files Handling
167
+
168
+
You can use `readFile`, `writeFile` and `removeFile` API to handle files inside your browser tests. All paths are resolved relative to the test file even if they are called in a helper function located in another file.
169
+
170
+
By default, Vitest uses `utf-8` encoding but you can override it with options.
171
+
172
+
::: tip
173
+
This API follows [`server.fs`](https://vitejs.dev/config/server-options.html#server-fs-allow) limitations for security reasons.
Vitest also implements Web Test Runner's [`sendKeys` API](https://modern-web.dev/docs/test-runner/commands/#send-keys). It accepts an object with a single property:
196
+
197
+
-`type` - types a sequence of characters, this API _is not_ affected by modifier keys, so having `Shift` won't make letters uppercase
198
+
-`press` - presses a single key, this API _is_ affected by modifier keys, so having `Shift` will make subsequent characters uppercase
199
+
-`up` - holds down a key (supported only with `playwright` provider)
200
+
-`down` - releases a key (supported only with `playwright` provider)
thrownewError(`Access denied to "${path}". See Vite config documentation for "server.fs": https://vitejs.dev/config/server-options.html#server-fs-strict.`)
0 commit comments