All skills
onmax avatar

/vitest

@de09c7b official
by Maxonmax/nuxt-skills715 stars
38

Vitest fast unit testing framework powered by Vite with Jest-compatible API. Use when writing tests, mocking, configuring coverage, or working with test filtering and fixtures.

Use this Skill: https://skilld.dev/gh/onmax/nuxt-skills/vitest

This session only. Nothing lands on disk.

referencescore-describe.md

≈906 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Describe API

Group related tests into suites for organization and shared setup.

Basic Usage

import { describe, expect, test } from 'vitest'

describe('Math', () => {
  test('adds numbers', () => {
    expect(1 + 1).toBe(2)
  })

  test('subtracts numbers', () => {
    expect(3 - 1).toBe(2)
  })
})

// Alias: suite
import { suite } from 'vitest'
suite('equivalent to describe', () => {})

Nested Suites

describe('User', () => {
  describe('when logged in', () => {
    test('shows dashboard', () => {})
    test('can update profile', () => {})
  })

  describe('when logged out', () => {
    test('shows login page', () => {})
  })
})

Suite Options

// All tests inherit options
describe('slow tests', { timeout: 30_000 }, () => {
  test('test 1', () => {}) // 30s timeout
  test('test 2', () => {}) // 30s timeout
})

Suite Modifiers

Skip Suites

describe.skip('skipped suite', () => {
  test('wont run', () => {})
})

// Conditional
describe.skipIf(process.env.CI)('not in CI', () => {})
describe.runIf(!process.env.CI)('only local', () => {})

Focus Suites

describe.only('only this suite runs', () => {
  test('runs', () => {})
})

Todo Suites

describe.todo('implement later')

Concurrent Suites

// All tests run in parallel
describe.concurrent('parallel tests', () => {
  test('test 1', async ({ expect }) => {})
  test('test 2', async ({ expect }) => {})
})

Opt Out of Concurrency

describe.sequential was removed in v5. Use { concurrent: false } to opt a suite out of inherited/global concurrency:

describe.concurrent('parallel', () => {
  test('concurrent 1', async () => {})

  describe('must be sequential', { concurrent: false }, () => {
    test('step 1', async () => {})
    test('step 2', async () => {})
  })
})

Shuffle Tests

describe.shuffle('random order', () => {
  test('test 1', () => {})
  test('test 2', () => {})
  test('test 3', () => {})
})

// Or with option
describe('random', { shuffle: true }, () => {})

Parameterized Suites

describe.each

describe.each([
  { name: 'Chrome', version: 100 },
  { name: 'Firefox', version: 90 },
])('$name browser', ({ name, version }) => {
  test('has version', () => {
    expect(version).toBeGreaterThan(0)
  })
})

describe.for

describe.for([
  ['Chrome', 100],
  ['Firefox', 90],
])('%s browser', ([name, version]) => {
  test('has version', () => {
    expect(version).toBeGreaterThan(0)
  })
})

Hooks in Suites

describe('Database', () => {
  let db

  beforeAll(async () => {
    db = await createDb()
  })

  afterAll(async () => {
    await db.close()
  })

  beforeEach(async () => {
    await db.clear()
  })

  test('insert works', async () => {
    await db.insert({ name: 'test' })
    expect(await db.count()).toBe(1)
  })
})

Modifier Combinations

Modifiers can be chained:

describe.skip.concurrent('skipped concurrent', () => {})
describe.only.shuffle('only and shuffled', () => {})

Key Points

  • Top-level tests belong to an implicit file suite
  • Nested suites inherit parent's options (timeout, retry, concurrency, etc.)
  • Hooks are scoped to their suite and nested suites
  • Use describe.concurrent with context's expect for snapshots
  • Shuffle order depends on sequence.seed config
  • describe.sequential was removed in v5 — use { concurrent: false }
<!-- Source references: - https://vitest.dev/api/describe.html -->

Source: SKILL.md on GitHub

No alerts9d5 checks · Risk SAFE
  • Gen Agent Trust Hub9d

    The skill is a comprehensive documentation set for the Vitest testing framework, providing configuration examples, API references, and CLI usage. No security issues were identified.

  • Socket9d

    No alerts

  • Snyk9d

    Risk: LOW · No issues

  • Runlayer7mo

    1/6 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at de09c7b. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 days ago.

Activeupdated last week
Other metadata
metadata
{
  "author": "Anthony Fu",
  "version": "2026.6.22",
  "source": "Generated from https://github.com/vitest-dev/vitest, scripts located at https://github.com/antfu/skills"
}

README badge

README badge for onmax/nuxt-skills/vitest

Configures and runs Vitest for unit and integration testing in Vite projects, with Jest-compatible syntax for writing test suites, mocking modules and timers, and executing tests in parallel. Use this when setting up test infrastructure for Vue, React, or Svelte components, or when writing type tests with TypeScript.

Generated from the current SKILL.md.

Does Vitest work with Vue, React, and Svelte components?
Yes. Vitest can test components from Vue, React, and Svelte. For component-specific patterns, the skill references a separate `vue` skill.
What environments does Vitest support for testing?
Vitest supports `node` and `jsdom` environments by default, with additional options for browser mode and type testing covered in the advanced reference.
Can I use Jest syntax with Vitest?
Yes. Vitest has a Jest-compatible API, so you can use familiar patterns like describe, it, expect, vi.fn, and vi.mock without syntax changes.
Does this skill cover mocking and test fixtures?
Yes. The skill includes reference files for mocking modules and timers with vi.fn and vi.mock, as well as test hooks and fixtures.

Generated from the current SKILL.md. These answers refresh after source changes.