new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Vitest · Guide · all subjects

browser/configuration

10 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Enable browser mode in config

To enable browser mode, set 'browser.enabled' to true in the Vitest configuration file. The browser.provider option must be specified, and at least one instance with a browser type must be configured.

Vitest browser port assignment

Vitest automatically assigns port 63315 for browser mode to avoid conflicts with the development server, allowing both to run in parallel. This port can be changed using the 'api' option in configuration.

Projects configuration for mixed node and browser tests

If you need to run some tests using Node-based runner and others in browser mode, define a 'projects' option with separate configurations. Each project can have its own test environment (node or browser) and file matching patterns.

Framework setup with vitest.config.ts

When using browser mode with frameworks, ensure the framework's plugin is installed and specified in the Vitest config. For example, React requires '@vitejs/plugin-react', Vue requires '@vitejs/plugin-vue', Svelte requires '@sveltejs/vite-plugin-svelte', etc. Some frameworks may require extra configuration.

Vitest configuration for browser debugging

Set inspectBrk to true and fileParallelism to false in vitest.config.js under the test property to enable browser debugging. Configure the browser provider and instances under the browser property.

Environment configuration example

import { defineConfig } from 'vitest/config' export default defineConfig({ test: { environment: 'happy-dom', // or 'jsdom', 'node' }, })

browser.viewport configuration

The browser.viewport configuration option accepts an object with width and height properties. The default viewport size is 414x896 pixels. This setting controls the default iframe viewport for browser mode tests.

Default browser viewport dimensions

The default browser viewport dimensions are 414 pixels wide by 896 pixels tall.

TestProject.browser property

The browser property will be set only if tests are running in the browser. If browser is enabled but tests did not run yet, this will be undefined. To check if the project supports browser tests, use the project.isBrowserEnabled() method.

TestProject.isBrowserEnabled() method

The isBrowserEnabled method returns true if the project runs tests in the browser.

Give your agent this brain