vitest-testing

existential-birds/beagle · updated Apr 8, 2026

$npx skills add https://github.com/existential-birds/beagle --skill vitest-testing
0 commentsdiscussion
summary

vitest-testing

skill.md

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)

Additional Documentation

Test Methods Quick Reference

Method Purpose
it() / test() Define test
describe() Group tests
beforeEach() / afterEach() Per-test hooks
beforeAll() / afterAll() Per-suite hooks
.skip Skip test/suite
.only Run only this
.todo Placeholder
.concurrent Parallel execution
.each([...]) Parameterized tests

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.746 reviews
  • Nia Perez· Dec 28, 2024

    vitest-testing is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Pratham Ware· Dec 24, 2024

    We added vitest-testing from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Chen Ndlovu· Dec 16, 2024

    vitest-testing fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Chen Lopez· Dec 16, 2024

    vitest-testing reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Carlos Yang· Nov 23, 2024

    Keeps context tight: vitest-testing is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Kiara Nasser· Nov 19, 2024

    vitest-testing reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Yash Thakker· Nov 15, 2024

    vitest-testing fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Valentina Brown· Nov 7, 2024

    We added vitest-testing from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Anika Srinivasan· Nov 7, 2024

    vitest-testing is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Valentina Patel· Oct 26, 2024

    Solid pick for teams standardizing on skills: vitest-testing is focused, and the summary matches what you get after install.

showing 1-10 of 46

1 / 5