vitest

vitest is a skill for Claude Code, Codex from andresquirogadev/skillsense. It costs 0 tokens per session (549 once invoked), scanned A, original, MIT.

A set of rules for writing tests with Vitest, a JavaScript and TypeScript testing tool. It covers test structure, assertions, mocking and cleanup.

In plain words
What is it for?
Writing and organising Vitest tests, checking expected behaviour, mocking modules and restoring test state.
Why use it?
It keeps tests consistent and helps prevent unreliable results caused by poorly isolated mocks or unclear test cases.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Writing and organising Vitest tests, checking expected behaviour, mocking modules and restoring test state.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/andresquirogadev/skillsense/vitest
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add andresquirogadev/skillsense --skill vitest
Clone the repo
git clone --depth 1 https://github.com/andresquirogadev/skillsense

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for vitest

README.md
[![agentmods](https://agentmods.dev/badge/skills/andresquirogadev/skillsense/vitest/github.svg)](https://agentmods.dev/skills/andresquirogadev/skillsense/vitest)
Your own site
<a href="https://agentmods.dev/skills/andresquirogadev/skillsense/vitest"><img src="https://agentmods.dev/badge/skills/andresquirogadev/skillsense/vitest/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for vitest

Your own site · 80×15
<a href="https://agentmods.dev/skills/andresquirogadev/skillsense/vitest"><img src="https://agentmods.dev/badge/skills/andresquirogadev/skillsense/vitest.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 549 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00549
Opus 5 $0.00000 $0.00275
Sonnet 5 $0.00000 $0.00110
Haiku 4.5 $0.00000 $0.00055

Measured 10d ago against content hash f62020021dea, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

vitest scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

packages/catalog/skills/vitest/SKILL.md · 49 lines

How it starts

The opening of the file, as written. The whole thing — 49 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Vitest Skill

You are writing tests with Vitest. Apply these conventions.

Test Structure

  • Use describe for grouping related tests; use it (or test) for individual cases.
  • Follow Arrange-Act-Assert (AAA) — keep each test focused on a single behavior.
  • Write test descriptions that read as specifications: it('returns 404 when user is not found').
  • Colocate test files next to source files (foo.test.ts) or put them in a tests/ directory — be consistent.

Assertions

  • Use Vitest's built-in expect with chainable matchers: .toBe(), .toEqual(), .toMatchObject(), .rejects.toThrow().
  • Use toEqual for deep equality of objects/arrays; use toBe only for primitive equality and reference checks.
  • Use toMatchInlineSnapshot() or toMatchSnapshot() for complex output — update with vitest --update-snapshots.

Mocking

  • Mock modules with vi.mock('module-name') at the top of the file — Vitest hoists these automatically.
  • Mock individual functions with vi.fn() or vi.spyOn(object, 'method').
  • Restore mocks after each test: use vi.restoreAllMocks() in afterEach, or set restoreMocks: true in config.
  • Stub globals with vi.stubGlobal('fetch', vi.fn()) — note that vi.stubGlobal is not hoisted.
  • Use vi.useFakeTimers() to control setTimeout, setInterval, and Date.

Async Tests

  • Always await promises in tests — unawaited rejections may be silently swallowed.
  • Use await expect(fn()).rejects.toThrow('message') for expected rejections.
  • Use vi.runAllTimersAsync() with fake timers to drain the async queue.

Setup & Teardown

  • Use beforeEach / afterEach for per-test setup/teardown.
  • Use beforeAll / afterAll for expensive shared setup (database connections, temp servers).
  • Clean up temp files and resources in afterEach — tests must be side-effect-free.

Configuration (vitest.config.ts)

export default defineConfig({
  test: {
    globals: true,          // no need to import describe/it/expect
    environment: 'node',    // or 'jsdom' for DOM tests
    coverage: { provider: 'v8', reporter: ['text', 'lcov'] },
  },
});

Read the full file on GitHub · 49 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 49 lines · 0 tokens per session scan A f62020021dea

Subscribe to this mod's changes

vitest is a skill published in the GitHub repository andresquirogadev/skillsense (2 stars, last pushed 5mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 549 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

ralphctl-debugging-and-error-recovery

Systematic root-cause debugging. Use when tests fail, builds break, or behaviour does not match expectations. Follow stop-the-line → reproduce → localize → reduce → root-cause → guard-with-regression-test → verify, not guessing; the reproduction and regression steps follow the same red-green discipline as…

lukas-grigis/ralphctl · 78 tokens

go-testing

Trigger: Go tests, go test coverage, Bubbletea teatest, golden files. Apply focused Go testing patterns.

Gentleman-Programming/gentle-ai · 26 tokens

testing

To write thorough, isolated, idempotent tests — 80%+ coverage, external-only mocking, scenario-driven.

griddynamics/rosetta · 26 tokens

ralphctl-test-driven-development

Execute-phase skill — write the failing test before the code that makes it pass; for bug fixes, this is the reproduction test itself. Use for any logic change, bug fix, or behavioural modification; for the full root-cause triage pipeline around an unexpected failure, see ralphctl-debugging-and-error-recovery.

lukas-grigis/ralphctl · 72 tokens

debugging

Use when debugging bugs, test failures, or unexpected behavior. Triggers: 'why isn't this working', 'this doesn't work', 'X is broken', 'something's wrong', 'getting an error', 'exception in', 'stopped working', 'regression', 'crash', 'hang', 'flaky test', 'intermittent failure', or when user pastes a stack…

axiomantic/spellbook · 104 tokens

ph-grill-me

(PH) Pressure-test a concrete decision, design, or plan only when the user asks to examine assumptions, alternatives, risks, or trade-offs.

jyt6640/persona-harness · 35 tokens