Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
existential-birds avatar

Vitest Testing

  • 442 installs
  • 74 repo stars
  • Updated July 21, 2026
  • existential-birds/beagle

vitest-testing is a beagle agent skill that teaches Vitest unit and integration testing patterns including vitest.config setup, vi.mock mocking, snapshots, coverage, and async assertions for TypeScript and JavaScript cod

About

vitest-testing is an existential-birds/beagle skill bundled in the beagle-react plugin for Vitest testing framework patterns and best practices. It triggers on describe, it, expect, vi.mock, vi.fn, beforeEach, afterEach, and vitest.config work. The main SKILL.md covers async testing with await on resolves/rejects matchers and a quick mock reference, while three deeper references split mocking, vitest.config.ts setup with v8 or istanbul coverage, and patterns for timers and snapshots. Developers reach for vitest-testing when setting up Vitest in TypeScript or JavaScript projects, debugging flaky async tests, configuring jsdom or node environments, or preparing CI-friendly coverage reports. Verification gates in the skill help catch silent false positives from missing await on async matchers.

  • Vitest config and Vite integration
  • Unit, component, and integration test patterns
  • Mocking, spies, and fixture setup
  • Coverage thresholds and watch mode
  • CI-ready test scripts and failure triage

Vitest Testing by the numbers

  • 442 all-time installs (skills.sh)
  • Ranked #633 of 2,153 Testing & QA skills by installs in the Skillselion catalog
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
npx skills add https://github.com/existential-birds/beagle --skill vitest-testing

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs442
repo stars74
Last updatedJuly 21, 2026
Repositoryexistential-birds/beagle

How do you set up Vitest mocks and coverage in TypeScript?

Set up Vitest, write unit and integration tests for TypeScript/JavaScript codebases, configure mocks, coverage, and CI-friendly test runs before release.

Who is it for?

TypeScript and JavaScript developers writing or fixing Vitest unit and integration tests before release.

Skip if: Jest-only codebases, end-to-end browser test suites, or teams not using the Vitest runner.

When should I use this skill?

A developer writes describe/it tests, configures vitest.config, uses vi.mock or vi.fn, or sets up Vitest coverage and async assertions.

What you get

Vitest test suites, vitest.config.ts files, mock setups, and coverage reports ready for CI runs.

  • Unit test files
  • vitest.config.ts
  • Coverage configuration

By the numbers

  • Includes 3 reference documents: mocking.md, config.md, and patterns.md

Files

SKILL.mdMarkdownGitHub ↗

Vitest Best Practices

Quick Reference

import { describe, it, expect, beforeEach, vi } from 'vitest'

describe('feature name', () => {
  beforeEach(() => {
    vi.clearAllMocks()
  })

  it('should do something specific', () => {
    expect(actual).toBe(expected)
  })

  it.todo('planned test')
  it.skip('temporarily disabled')
  it.only('run only this during dev')
})

Common Assertions

// Equality
expect(value).toBe(42)                    // Strict (===)
expect(obj).toEqual({ a: 1 })             // Deep equality
expect(obj).toStrictEqual({ a: 1 })       // Strict deep (checks types)

// Truthiness
expect(value).toBeTruthy()
expect(value).toBeFalsy()
expect(value).toBeNull()
expect(value).toBeUndefined()

// Numbers
expect(0.1 + 0.2).toBeCloseTo(0.3)
expect(value).toBeGreaterThan(5)

// Strings/Arrays
expect(str).toMatch(/pattern/)
expect(str).toContain('substring')
expect(array).toContain(item)
expect(array).toHaveLength(3)

// Objects
expect(obj).toHaveProperty('key')
expect(obj).toHaveProperty('nested.key', 'value')
expect(obj).toMatchObject({ subset: 'of properties' })

// Exceptions
expect(() => fn()).toThrow()
expect(() => fn()).toThrow('error message')
expect(() => fn()).toThrow(/pattern/)

Async Testing

// Async/await (preferred)
it('fetches data', async () => {
  const data = await fetchData()
  expect(data).toEqual({ id: 1 })
})

// Promise matchers - ALWAYS await these
await expect(fetchData()).resolves.toEqual({ id: 1 })
await expect(fetchData()).rejects.toThrow('Error')

// Wrong - creates false positive
expect(promise).resolves.toBe(value)  // Missing await!

Quick Mock Reference

const mockFn = vi.fn()
mockFn.mockReturnValue(42)
mockFn.mockResolvedValue({ data: 'value' })

expect(mockFn).toHaveBeenCalled()
expect(mockFn).toHaveBeenCalledWith('arg1', 'arg2')
expect(mockFn).toHaveBeenCalledTimes(2)

Verification gates

Use this sequence when you add or change tests; each step has an objective pass condition.

1. Run the test suite — From the package or workspace root, run the same command CI uses (check package.json scripts; often vitest run, pnpm test, or npm test). Pass: exit code is 0 and the report shows zero failing tests. 2. Async matchersPass: every expect(…).resolves and expect(…).rejects is prefixed with await (await expect(...)), as in Async Testing. A line where resolves or rejects appears without await fails this gate.

Additional Documentation

  • Mocking: See references/mocking.md for module mocking, spying, cleanup
  • Configuration: See references/config.md for vitest.config, setup files, coverage
  • Patterns: See references/patterns.md for timers, snapshots, anti-patterns

Test Methods Quick Reference

MethodPurpose
it() / test()Define test
describe()Group tests
beforeEach() / afterEach()Per-test hooks
beforeAll() / afterAll()Per-suite hooks
.skipSkip test/suite
.onlyRun only this
.todoPlaceholder
.concurrentParallel execution
.each([...])Parameterized tests

Related skills

How it compares

Use vitest-testing for Vitest-specific vi.mock and vitest.config patterns; pick Jest-oriented skills when the project has not migrated to Vitest.

FAQ

What Vitest APIs does vitest-testing document?

vitest-testing documents describe, it, expect, vi.mock, vi.fn, vi.spyOn, beforeEach, afterEach, and vitest.config setup. The beagle skill includes separate references for mocking, configuration, and timer or snapshot patterns.

Does vitest-testing cover async test pitfalls?

vitest-testing emphasizes awaiting resolves and rejects matchers to avoid silent false positives in async Vitest tests. The skill includes verification gates and a dedicated async testing section in the main SKILL.md.

Testing & QAtestingfrontendbackend

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.