vitest

vitest is a skill for Claude Code, Codex from Plazmodium/odin-workflow. It costs 55 tokens per session (1,550 once invoked), scanned A, original, MIT.

A guide to Vitest, a testing framework for JavaScript and TypeScript projects, especially those using Vite or modern module imports. It covers tests, mocks, component testing, and running tests during development.

In plain words
What is it for?
Use it to create unit, component, and related tests; mock dependencies; check coverage; migrate from Jest; and test Vue, React, or other modern JavaScript projects.
Why use it?
It helps teams write and run tests using conventions that fit Vite-based projects instead of adapting older testing setups.

Skill for Claude CodeCodex

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

Good fit Use it to create unit, component, and related tests; mock dependencies; check…

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/plazmodium/odin-workflow/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 Plazmodium/odin-workflow --skill vitest
Clone the repo
git clone --depth 1 https://github.com/Plazmodium/odin-workflow

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/plazmodium/odin-workflow/vitest.svg)](https://agentmods.dev/skills/plazmodium/odin-workflow/vitest)
Your own site
<a href="https://agentmods.dev/skills/plazmodium/odin-workflow/vitest"><img src="https://agentmods.dev/badge/skills/plazmodium/odin-workflow/vitest.svg" alt="Measured on agentmods" height="20"></a>
Per session 55 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,550 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.00055 $0.01550
Opus 5 $0.00028 $0.00775
Sonnet 5 $0.00011 $0.00310
Haiku 4.5 $0.00006 $0.00155

Measured 6d ago against content hash b85f7de4120c, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, 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 6d 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.

agents/skills/testing/vitest/SKILL.md · 250 lines

How it starts

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

Vitest Testing Framework

Instructions

  1. Assess the project: Vitest is ideal for Vite-based projects and ESM-first codebases.
  2. Follow Vitest conventions:
    • Test files: *.test.ts, *.spec.ts
    • API is Jest-compatible but with modern ESM imports
    • Leverages Vite's transform pipeline for fast tests
  3. Provide complete examples: Include proper ESM imports and TypeScript types.
  4. Highlight Vitest features: In-source testing, browser mode, UI.
  5. Guide on migration: Help users migrating from Jest.

Test Structure

import { describe, it, expect, beforeEach, vi } from 'vitest';
import { myFunction } from './myModule';

describe('myFunction', () => {
  beforeEach(() => {
    vi.clearAllMocks();
  });

  it('should return expected value', () => {
    expect(myFunction('input')).toBe('output');
  });

  it('should handle async operations', async () => {
    const result = await myFunction('async');
    expect(result).toBe('done');
  });
});

Mocking with vi

Mock a module

vi.mock('./database', () => ({
  query: vi.fn().mockResolvedValue([{ id: 1 }]),
}));

Mock a function

const mockFn = vi.fn((x: number) => x + 1);
expect(mockFn(1)).toBe(2);
expect(mockFn).toHaveBeenCalledWith(1);

Spy on methods

const spy = vi.spyOn(object, 'method');
object.method();
expect(spy).toHaveBeenCalled();
spy.mockRestore();

Mock timers

vi.useFakeTimers();
setTimeout(callback, 1000);
vi.advanceTimersByTime(1000);
expect(callback).toHaveBeenCalled();
vi.useRealTimers();

Mock globals

vi.stubGlobal('fetch', vi.fn().mockResolvedValue({
  json: () => Promise.resolve({ data: 'mocked' }),
}));

In-Source Testing

Vitest supports tests directly in source files:

// src/utils.ts
export function add(a: number, b: number): number {
  return a + b;
}

if (import.meta.vitest) {
  const { describe, it, expect } = import.meta.vitest;

  describe('add', () => {
    it('adds two numbers', () => {
      expect(add(1, 2)).toBe(3);
    });
  });
}

Read the full file on GitHub · 250 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. 6d ago First seen · 250 lines · 55 tokens per session scan A b85f7de4120c

Subscribe to this mod's changes

vitest is a skill published in the GitHub repository Plazmodium/odin-workflow (0 stars, last pushed 3mo ago), licensed MIT. It adds 55 tokens to every session and 1,550 once invoked, about $0.0003 per session on Opus 5. 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-09-01.

Related

Other skills, from other repositories

api-testing

Testing patterns for MCP tool/resource handlers using createMockContext and Vitest. Covers mock context options, handler testing, McpError assertions, format testing, Vitest config setup, and test isolation conventions.

cyanheads/pubmed-mcp-server · 46 tokens

api-testing

Testing patterns for MCP tool/resource handlers using createMockContext and Vitest. Covers mock context options, handler testing, McpError assertions, format testing, Vitest config setup, and test isolation conventions.

cyanheads/sports-mcp-server · 46 tokens

api-testing

Testing patterns for MCP tool/resource handlers using createMockContext and Vitest. Covers mock context options, handler testing, McpError assertions, format testing, Vitest config setup, and test isolation conventions.

cyanheads/internet-archive-mcp-server · 46 tokens

api-testing

Testing patterns for MCP tool/resource handlers using createMockContext and Vitest. Covers mock context options, handler testing, McpError assertions, format testing, Vitest config setup, and test isolation conventions.

cyanheads/smithsonian-mcp-server · 46 tokens

api-testing

Testing patterns for MCP tool/resource handlers using createMockContext and Vitest. Covers mock context options, handler testing, McpError assertions, format testing, Vitest config setup, and test isolation conventions.

cyanheads/stackexchange-mcp-server · 46 tokens

add-test

Scaffold a test file for an existing tool, resource, or service. Use when the user asks to add tests, improve coverage, or when a definition exists without a matching test file.

cyanheads/stackexchange-mcp-server · 41 tokens