Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

vitest

БесплатноБез исполняемых скриптовНе проверен

Vitest testing framework: Vite-powered tests, Jest-compatible API, mocking, snapshots, coverage, browser mode, and TypeScript support. Use when writing or…

itechmeatот itechmeat★ 24 звезды на GitHub

Об этом скилле

Vitest

Next generation testing framework powered by Vite.

Quick Navigation

When to Use

  • Testing Vite-based applications (shared config)
  • Need Jest-compatible API with native ESM support
  • Component testing in real browser
  • Fast watch mode with HMR
  • TypeScript testing without extra config
  • Parallel test execution

Installation

Install: npm install -D vitest. Requires Node.js >=22 and Vite >=6.4 in v5.

Release Highlights (5.0.0)

  • Requirements: Node.js >=22 and Vite >=6.4 are required. @vitest/runner is inlined (the package is no longer published) and expect is inlined, so old entry points were removed.
  • Mock/timer behavior: mocks are cleared by default before each test, and Temporal can now be mocked (with or without fake timers).
  • Replaced APIs: sequential test/suite options are removed in favor of concurrent; the webdriverio browser provider is removed; toHaveTextContent is strict with toMatchTextContent as the alternative; expect.poll fails when the function does not resolve in time.
  • New defaults/outputs: attachmentsDir defaults to .vitest/attachments/ (was .vitest-attachments/), and blob/json/junit/html reporter outputs default to .vitest; a createReport API and .vitest report directory convention are introduced.
  • Projects: inline projects extend the root config by default, nested projects are supported, distinct projects share one Vite server, and the config file is no longer looked up from ancestor directories (parent dirs no longer apply).
  • Browser: locator objects replace locator strings, locators.exact is on by default, and a screenshotDirectory config controls toMatchScreenshot output.
  • Misc: benchmark public API was rewritten with a pluggable provider API; -p is a shorthand for --project; -t uses > as separator; coverage thresholds.perFile accepts an object and TypeScript build mode / vitest list static parsing are supported.

Patch Notes (5.0.1 -> 5.0.5)

  • 5.0.2 to 5.0.5 are fixes only — the 5.0 API surface is unchanged.
  • The root temp directory is removed when the run closes, and --changed handles quoted file names.
  • import.meta.hot stubs expose data, skipIf sets skip and ignores undefined options, and the native loader keeps the import frame inside its errors.
  • Browser mode: late connections of closed sessions are dropped, global setup runs once with instances, the browser waits up to 30s to close, and synthetic pagehide events are ignored.
  • Hook cleanups run even when a later hook fails, mocks of finished test files are released, and all running tests are aborted on cancel.
  • The reporter reports end reason failed when a worker crashes.

Release Highlights (4.1.0 -> 4.1.6)

  • New control-flow hooks: aroundEach and aroundAll.
  • Test metadata expands with tags, meta, and improved test.extend type inference.
  • CLI adds --detect-async-leaks, richer --update modes, and static collection for vitest list.
  • Browser mode grows Playwright persistent contexts, userEvent.wheel, and stronger trace/artifact handling.
  • Mocking/timers add disposable doMock(), mockThrow / mockThrowOnce, and setTickMode.
  • 4.1.4 adds experimental ARIA snapshots, filterMeta for the JSON reporter, and exposes assertion as a public experimental field.
  • 4.1.5 adds coverage instrumenter support and improves reporter/UI behavior around large snapshots and HTML output.
  • 4.1.6 tightens browser screenshot path resolution and fixes sequence.concurrent handling for concurrent test scheduling.

Quick Start

// sum.js
export function sum(a, b) {
  return a + b;
}
// sum.test.js
import { expect, test } from "vitest";
import { sum } from "./sum.js";

test("adds 1 + 2 to equal 3", () => {
  expect(sum(1, 2)).toBe(3);
});
// package.json
{
  "scripts": {
    "test": "vitest",
    "test:run": "vitest run",
    "coverage": "vitest run --coverage"
  }
}

Configuration

// vitest.config.ts (recommended)
import { defineConfig } from "vitest/config";

export default defineConfig({
  test: {
    globals: true, // Enable global test APIs
    environment: "jsdom", // Browser-like environment
    include: ["**/*.{test,spec}.{js,ts,jsx,tsx}"],
    coverage: {
      provider: "v8",
      reporter: ["text", "html"],
    },
  },
});

Or extend Vite config:

// vite.config.ts
/// <reference types="vitest/config" />
import { defineConfig } from "vite";

export default defineConfig({
  test: {
    // test options
  },
});

Test File Naming

By default, test

Полный SKILL.md на GitHub

Установить vitest в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/api.mdreferences/browser.mdreferences/cli.mdreferences/config.mdreferences/expect.mdreferences/mocking.md

FAQ

Что делает скилл vitest?

Vitest testing framework: Vite-powered tests, Jest-compatible API, mocking, snapshots, coverage, browser mode, and TypeScript support. Use when writing or configuring tests with Vitest, setting up mocking/snapshots, configuring coverage, or running browser-mode tests. Keywords: Vitest, testing, Vite, Jest, mocking, coverage.

Как установить скилл vitest?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл vitest запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить vitest с