Skip to content

browser.api

  • Type: number | object
  • Default: 63315
  • CLI: --browser.api=63315, --browser.api.port=1234, --browser.api.host=example.com

Configure options for Vite server that serves code in the browser. Does not affect test.api option. By default, Vitest assigns port 63315 to avoid conflicts with the development server, allowing you to run both in parallel.

api.allowWrite 4.1.0+

  • Type: boolean
  • Default: true if not exposed to the network, false otherwise

Vitest saves annotation attachments, artifacts and snapshots by receiving a WebSocket connection from the browser. This allows anyone who can connect to the API write any arbitary code on your machine within the root of your project (configured by fs.allow).

If browser server is not exposed to the internet (the host is localhost), this should not be a problem, so the default value in that case is true. If you override the host, Vitest will set allowWrite to false by default to prevent potentially harmful writes.

api.allowExec 4.1.0+

  • Type: boolean
  • Default: true if not exposed to the network, false otherwise

Allows running any test file via the UI. This only applies to the interactive elements (and the server code behind them) in the UI that can run the code. If UI is disabled, this has no effect. See api.allowExec for more information.