vitest
Audited by Runlayer on Feb 21, 2026
Malicious tool definition detected
Tool: references/advanced-environments.md Description: --- name: test-environments description: Configure environments like jsdom, happy-dom for browser APIs --- # Test Environments ## Available Environments - `node` (default) - Node.js environment - `jsdom` - Browser-like with DOM APIs - `happy-dom` - Faster alternative to jsdom - `edge-runtime` - Vercel Edge Runtime ## Configuration ```ts // vitest.config.ts defineConfig({ test: { environment: 'jsdom', // Environment-specific options environme
Malicious tool definition detected
## Basic Projects Setup ```ts // vitest.config.ts defineConfig({ test: { projects: [ // Glob patterns for config files 'packages/*', // Inline config { test: { name: 'unit', include: ['tests/unit/**/*.test.ts'], environment: 'node', }, }, { test: { name: 'integration', include: ['tests/integration/**/*.test.ts'], environment: 'jsdom', }, }, ], }, }) ``` ## Monorepo Pattern ```ts defineConfig({ test: { projects: [ // Each package has its own vitest.config.ts 'packages/core', 'packages/cli', 'pack
Malicious tool definition detected
Tool: references/advanced-type-testing.md Description: --- name: type-testing description: Test TypeScript types with expectTypeOf and assertType --- # Type Testing Test TypeScript types without runtime execution.
Malicious tool definition detected
Tool: references/core-cli.md Description: --- name: vitest-cli description: Command line interface commands and options --- # Command Line Interface ## Commands ### `vitest` Start Vitest in watch mode (dev) or run mode (CI): ```bash vitest # Watch mode in dev, run mode in CI vitest foobar # Run tests containing "foobar" in path vitest basic/foo.test.ts:10 # Run specific test by file and line number ``` ### `vitest run` Run tests once without watch mode: ```bash vi
Malicious tool definition detected
Tool: references/core-config.md Description: --- name: vitest-configuration description: Configure Vitest with vite.config.ts or vitest.config.ts --- # Configuration Vitest reads configuration from `vitest.config.ts` or `vite.config.ts`.
Malicious tool definition detected
name: expect.any(String), }) expect({ a: 1, b: 2, c: 3 }).toEqual( expect.objectContaining({ a: 1 }) ) expect([1, 2, 3, 4]).toEqual( expect.arrayContaining([1, 3]) ) expect('hello world').toEqual( expect.stringContaining('world') ) expect('hello world').toEqual( expect.stringMatching(/world$/) ) expect({ value: null }).toEqual({ value: expect.anything() // Matches anything except null/undefined }) // Negate with expect.not expect([1, 2]).toEqual( expect.not.arrayContaining([3]) ) ``` ## Soft Ass
Malicious tool definition detected
Tool: references/core-hooks.md Description: --- name: lifecycle-hooks description: beforeEach, afterEach, beforeAll, afterAll, and around hooks --- # Lifecycle Hooks ## Basic Hooks ```ts import { afterAll, afterEach, beforeAll, beforeEach, test } from 'vitest' beforeAll(async () => { // Runs once before all tests in file/suite await setupDatabase() }) afterAll(async () => { // Runs once after all tests in file/suite await teardownDatabase() }) beforeEach(async () => { // Runs before each test aw
Malicious tool definition detected
Tool: references/features-concurrency.md Description: --- name: concurrency-parallelism description: Concurrent tests, parallel execution, and sharding --- # Concurrency & Parallelism ## File Parallelism By default, Vitest runs test files in parallel across workers: ```ts defineConfig({ test: { // Run files in parallel (default: true) fileParallelism: true, // Number of worker threads maxWorkers: 4, minWorkers: 1, // Pool type: 'threads', 'forks', 'vmThreads' pool: 'threads', }, }) ``` ## Concur
Malicious tool definition detected
Tool: references/features-context.md Description: --- name: test-context-fixtures description: Test context, custom fixtures with test.extend --- # Test Context & Fixtures ## Built-in Context Every test receives context as first argument: ```ts test('context', ({ task, expect, skip }) => { console.log(task.name) // Test name expect(1).toBe(1) // Context-bound expect skip() // Skip test dynamically }) ``` ### Context Properties - `task` - Test metadata (name, file, etc.) -
Malicious tool definition detected
test('slow test', { tags: ['slow', 'integration'] }, () => {}) ``` Run tagged tests: ```bash vitest --tags db vitest --tags "db,slow" # OR vitest --tags db --tags slow # OR ``` Configure allowed tags: ```ts defineConfig({ test: { tags: ['db', 'slow', 'integration'], strictTags: true, // Fail on unknown tags }, }) ``` ## Include/Exclude Patterns ```ts defineConfig({ test: { // Test file patterns include: ['**/*.{test,spec}.{ts,tsx}'], // Exclude patterns exclude: [ '**/node_modules/**', '**/
Tool passed security scan
Tool passed security scan
Passed Files (6)Click to expand
Tool passed security scan
Tool passed security scan
Tool passed security scan
Tool passed security scan
Tool passed security scan
Tool passed security scan