A solid reference for Vitest that covers the essentials without the fluff. You get common assertions, async testing patterns with the critical await reminders, and a quick mock reference. The verification gates are actually useful, especially the async matcher check since forgetting await on resolves/rejects creates silent false positives. It splits deeper topics like module mocking and configuration into separate references, which keeps the main doc scannable. Best used when you're writing tests and need to confirm syntax or catch yourself before making the usual mistakes. Not a tutorial, just the patterns you'd otherwise grep the docs for.

skills.sh installs
471
GitHub stars
87
last updated
Aug 21, 2026

Install

$ npx -y skills add existential-birds/beagle --skill vitest-testing --agent claude-code

Installs into .claude/skills of the current project.

Files

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' })

Sponsors

Details

Repository
github.com/existential-birds/beagle
Categories
Testing & QA, Documentation
First seen
Jun 3, 2026

More from existential-birds/beagle

All 40
1umbraco avatarumbraco-e2e-testingumbraco/umbraco-cms-backoffice-skillsE2E testing for Umbraco backoffice extensions using Playwright and @umbraco-cms/acceptance-test-helpers380skills.sh installs
2patricio0312rev avatarunit-test-generatorpatricio0312rev/skillsGenerates comprehensive unit tests with AAA pattern (Arrange-Act-Assert), edge cases, error scenarios, and coverage analysis. Creates test files matching source374skills.sh installs
3patricio0312rev avatarcypress-playwright-setuppatricio0312rev/skillsSets up end-to-end testing with Cypress or Playwright including page objects, fixtures, and CI integration. Use when users request "E2E testing", "Cypress setup309skills.sh installs
4patricio0312rev avatare2e-test-builderpatricio0312rev/skillsBuilds end-to-end browser tests for critical user flows using Playwright or Cypress. Includes selector strategies, test data management, page objects, and visua269skills.sh installs
5giuseppe-trisciuoglio avatarunit-test-bean-validationgiuseppe-trisciuoglio/developer-kitProvides patterns for unit testing Jakarta Bean Validation (JSR-380), including @Valid, @NotNull, @Min, @Max, @Email constraints with Hibernate Validator. Gener5Kskills.sh installs
6giuseppe-trisciuoglio avatarunit-test-wiremock-rest-apigiuseppe-trisciuoglio/developer-kitProvides patterns for unit testing external REST APIs using WireMock. Stubs API responses, verifies request details, simulates failures (timeouts, 4xx/5xx error3.9Kskills.sh installs