{
 "kind": "tool",
 "slug": "vitest",
 "path": "tools/vitest/",
 "name": "Vitest",
 "maker": null,
 "density": "full",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Testing",
   "tools/testing/"
  ]
 ],
 "lead": "Automatic tests for JavaScript and TypeScript apps.",
 "chips": [
  {
   "label": "Testing",
   "path": "tools/testing/"
  },
  {
   "label": "NPM"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "npm install vitest"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/vitest-dev/vitest"
  },
  {
   "label": "Website",
   "href": "https://vitest.dev"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "MIT",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software",
   "note": "MIT allows use in paid and closed-source projects.",
   "src": "https://github.com/vitest-dev/vitest/blob/main/LICENSE"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Nov 24, 2026",
   "note": "Latest GitHub release Nov 17, 2026. ",
   "src": "https://github.com/vitest-dev/vitest"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "1,312 projects",
   "status": "info",
   "sub": "#1 of 122 in its category",
   "note": "Dependency in 1,312 public GitHub projects set up for AI coding agents that we scanned (21.0%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Docs for agents",
   "status": "yes",
   "sub": "llms.txt",
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": "https://vitest.dev/llms.txt"
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily; card checked Nov 10, 2026.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What Vitest does",
   "parts": [
    {
     "t": "prose",
     "text": "Vitest is a free tool that runs automatic tests for JavaScript and TypeScript code. You or your AI assistant write small checks such as \"adding 1 and 2 gives 3\", and Vitest runs them again on every change and shows what broke. It fits projects built with Vite and reads the same settings."
    },
    {
     "t": "h3",
     "text": "What people build with it"
    },
    {
     "t": "uses",
     "items": [
      {
       "title": "Check that your functions still work",
       "text": "Write a few small checks for prices, dates or form rules; every change reruns them and a red line shows what broke.",
       "idea": false
      },
      {
       "title": "Keep AI-written code honest",
       "text": "Ask your assistant to add tests with each change, then review them; the guide explains what good prompts and good tests look like.",
       "idea": false
      },
      {
       "title": "Test page parts without a browser",
       "text": "Check that a form or button component renders and reacts, using a simulated page that runs fast in the terminal.",
       "idea": false
      },
      {
       "title": "Test in a real browser",
       "text": "For parts that depend on real layout or browser behaviour, run the same tests inside Chromium through Playwright.",
       "idea": false
      },
      {
       "title": "See which code no test touches",
       "text": "A coverage report lists the lines your tests never ran, so you know where a bug could hide.",
       "idea": false
      },
      {
       "title": "Move an old Jest project over",
       "text": "Existing Jest tests mostly keep working, so a project can switch runners with a few small edits.",
       "idea": false
      }
     ]
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "Vitest popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "86",
       "of": "/ 100",
       "l": "Gid Score, #30 overall"
      },
      {
       "n": "194M",
       "l": "downloads a week, npm"
      },
      {
       "n": "17.4K",
       "l": "GitHub stars"
      },
      {
       "n": "1,312",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How Vitest is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "Vitest is a dependency in 1,312 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (27.0% of the 4,867 JavaScript/TypeScript ones), #1 of 122 in testing.",
      "Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 3,365; those are left out of every share on this page.",
      "The most used alternative in our scan is Jest (396 projects).",
      "Projects that use it most often also use jsdom (41.4%), TypeScript (93.7%), Vite (50.5%).",
      "It is more common in projects set up for OpenAI Codex (31.1%) than for Cursor (20.3%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "854 projects, 26.1%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "620 projects, 20.4%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "495 projects, 20.3%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "146 projects, 30.8%",
       "v": "Gemini CLI",
       "path": "agents/gemini-cli/"
      },
      {
       "l": "146 projects, 31.1%",
       "v": "OpenAI Codex",
       "path": "agents/openai-codex/"
      },
      {
       "l": "96 projects, 28.7%",
       "v": "OpenClaw",
       "path": "agents/openclaw/"
      },
      {
       "l": "95 projects, 27.7%",
       "v": "OpenCode",
       "path": "agents/opencode/"
      },
      {
       "l": "60 projects, 21.5%",
       "v": "Devin Desktop",
       "path": "agents/devin-desktop/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 41.4% of its projects",
       "v": "jsdom",
       "path": "tools/jsdom/"
      },
      {
       "l": "In 93.7% of its projects",
       "v": "TypeScript",
       "path": "tools/typescript/"
      },
      {
       "l": "In 50.5% of its projects",
       "v": "Vite",
       "path": "tools/vite/"
      },
      {
       "l": "In 36.1% of its projects",
       "v": "Testing Library",
       "path": "tools/testing-library/"
      },
      {
       "l": "In 63.0% of its projects",
       "v": "ESLint",
       "path": "tools/eslint/"
      },
      {
       "l": "In 41.9% of its projects",
       "v": "Playwright (JavaScript)",
       "path": "tools/playwright-test/"
      },
      {
       "l": "In 37.4% of its projects",
       "v": "tsx",
       "path": "tools/tsx/"
      },
      {
       "l": "In 48.1% of its projects",
       "v": "Zod",
       "path": "tools/zod/"
      }
     ]
    }
   ]
  },
  {
   "id": "profile",
   "nav": "Profile",
   "h2": "Vitest in practice",
   "parts": [
    {
     "t": "h3",
     "text": "Strengths"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Your Vite config is your test config",
       "v": "Vitest reads <code>vite.config.*</code> by default, so existing Vite plugins and settings apply to tests with no extra setup. A separate <code>vitest.config.*</code> is optional and holds only test-specific settings."
      },
      {
       "l": "Built to stand in for Jest",
       "v": "The docs say the API is compatible enough to serve as \"a drop-in replacement in most projects.\" Mocking, snapshots and coverage come included."
      },
      {
       "l": "Watch mode modeled on HMR",
       "v": "The site says watch mode reruns only the tests related to a change, \"just like HMR for tests.\""
      },
      {
       "l": "Tests in a real browser, not only a fake DOM",
       "v": "Browser Mode runs tests natively in a browser. The maintainers write that they built it to get \"more accurate and reliable test results\" than simulated environments give."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Watch out for"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Recent Vite and Node only",
       "v": "The current docs state that Vitest requires Vite <code>&gt;=v6.4.0</code> and Node <code>&gt;=v22.12.0</code>."
      },
      {
       "l": "Browser Mode is not an E2E runner",
       "v": "The docs call Browser Mode \"Not a Drop-In Replacement\" for standalone end-to-end runners. They recommend adding WebdriverIO, Cypress or Playwright."
      },
      {
       "l": "Browser Mode is slower to start",
       "v": "A provider and a browser must start before any test runs. The docs warn this can mean longer initialization than other testing patterns."
      }
     ]
    },
    {
     "t": "h3",
     "text": "A suite mixing expect, Chai assert and snapshots"
    },
    {
     "t": "tabs",
     "label": "Example",
     "items": [
      {
       "tab": "Ts",
       "code": "import { assert, describe, expect, it } from 'vitest'\n\ndescribe('suite name', () => {\n  it('foo', () => {\n    expect(1 + 1).toEqual(2)\n    expect(true).to.be.true\n  })\n\n  it('bar', () => {\n    assert.equal(Math.sqrt(4), 2)\n  })\n\n  it('snapshot', () => {\n    expect({ foo: 'bar' }).toMatchSnapshot()\n  })\n})"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "profile",
   "h2": "More about Vitest",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Funding",
       "path": "tools/funding/",
       "items": [
        "GitHub Sponsors: https://github.com/vitest-dev",
        "Open Collective: https://opencollective.com/vitest",
        "19 GitHub sponsors"
       ]
      },
      {
       "title": "Agent Skills for it",
       "path": "skills/",
       "items": [
        "vitest: Vitest fast unit testing framework powered by Vite with Jest-compatible API. Use when writing tests, mocking, configuring coverage, or worki",
        "vitest: Vitest fast unit testing framework powered by Vite with Jest-compatible API. Use when writing tests, mocking, configuring coverage, or worki"
       ]
      },
      {
       "title": "Head to head",
       "items": [
        {
         "text": "Vitest vs Jest",
         "note": "used together in 61 projects",
         "path": "tools/compare/vitest-vs-jest/"
        },
        {
         "text": "Vitest vs Nx Jest Plugin",
         "note": "used together in 24 projects",
         "path": "tools/compare/vitest-vs-nx-jest-plugin/"
        }
       ]
      },
      {
       "title": "Packages around it",
       "items": [
        "@vitest/coverage-v8: V8 coverage provider",
        "@vitest/ui: Vitest UI",
        "@vitest/browser-playwright: Browser Mode via Playwright",
        "@vitest/browser: Browser Mode",
        "@vitest/eslint-plugin: ESLint rules for Vitest",
        "@vitest/coverage-istanbul: Istanbul coverage provider"
       ]
      },
      {
       "title": "More in Testing",
       "path": "tools/testing/",
       "items": [
        {
         "text": "Playwright (JavaScript)",
         "path": "tools/playwright-test/"
        },
        {
         "text": "Testing Library",
         "path": "tools/testing-library/"
        },
        {
         "text": "jsdom",
         "path": "tools/jsdom/"
        },
        {
         "text": "pytest",
         "path": "tools/pytest/"
        },
        {
         "text": "Happy DOM",
         "path": "tools/happy-dom/"
        },
        {
         "text": "axe-core Playwright",
         "path": "tools/axe-core-playwright/"
        },
        {
         "text": "SuperTest",
         "path": "tools/supertest/"
        },
        {
         "text": "Mock Service Worker",
         "path": "tools/msw/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "Vitest",
       "me": true,
       "facts": [
        "MIT",
        "Gid 86",
        "194M/wk"
       ]
      },
      {
       "name": "Jest",
       "why": "Pick Jest when an existing project already runs on it and you do not want to switch.",
       "path": "tools/jest/",
       "facts": [
        "MIT",
        "Gid 86",
        "63.2M/wk"
       ]
      },
      {
       "name": "Playwright (JavaScript)",
       "why": "Pick Playwright Test for end-to-end tests that click through the whole app in several browsers.",
       "path": "tools/playwright-test/",
       "facts": []
      },
      {
       "name": "pytest",
       "why": "Pick pytest when the code under test is Python.",
       "path": "tools/pytest/",
       "facts": []
      },
      {
       "name": "Nx Jest Plugin",
       "why": "Nx plugin providing Jest testing capabilities and executors for monorepo projects.",
       "path": "tools/nx-jest/",
       "facts": [
        "MIT",
        "Gid 66",
        "4.5M/wk"
       ]
      }
     ],
     "more": "Compare Vitest with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "prompt",
     "text": "Add vitest 5.1.0 (Node.js 22.12+, Vite 6.4+) with a \"test\" script, import test and expect from 'vitest' in every test file, keep vi.mock calls at the top level, await every .resolves or .rejects assertion, and run npx vitest run before you finish."
    },
    {
     "t": "steps",
     "items": [
      {
       "text": "Add Vitest to the project as a development tool (it needs Node.js 22.12 or newer and Vite 6.4 or newer).",
       "code": "npm install -D vitest",
       "src": "https://vitest.dev/guide/"
      },
      {
       "text": "Add a test script to package.json and run it.",
       "code": "{\n  \"scripts\": {\n    \"test\": \"vitest\"\n  }\n}\n",
       "src": "https://vitest.dev/guide/"
      },
      {
       "text": "In CI or for one-off checks, run once instead of watching.",
       "code": "npx vitest run",
       "src": "https://vitest.dev/guide/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Rules for your agent"
    },
    {
     "t": "rules",
     "label": "Paste into AGENTS.md or CLAUDE.md",
     "text": "## Vitest\n- Install as a dev dependency (`npm install -D vitest`). Check that the project has Vite >=v6.4.0 and Node >=v22.12.0.\n- Name test files with `.test.` or `.spec.` in the file name. By default, other files are not picked up as tests.\n- Put test settings in the existing `vite.config.*`. Create a separate `vitest.config.*` only for test-specific settings.\n- Use `vitest run` to run tests once without watching. Plain `vitest` runs in watch mode, which is the default.\n- Import test APIs explicitly, for example `import { describe, expect, it } from 'vitest'`.\n- Add `.vitest/` to `.gitignore`, because Vitest and its integrations store generated artifacts there.\n- On Bun, run tests with `bun run test`, never `bun test`.\n"
    },
    {
     "t": "h3",
     "text": "Mistakes to avoid"
    },
    {
     "t": "mistakes",
     "items": [
      {
       "dont": "Calling describe, it and expect without importing them (Jest habit)",
       "fix": "import { describe, it, expect, vi } from 'vitest' in each file, or set test.globals: true in the config",
       "why": "Vitest does not turn global test functions on by default."
      },
      {
       "dont": "vi.mock('./calculator') inside a describe or test callback",
       "fix": "Put vi.mock at the top level of the file (or use vi.doMock where it must run in place)",
       "why": "vi.mock is hoisted to the top of the file; since 5.0 a nested call throws instead of warning."
      },
      {
       "dont": "expect(promise).resolves.toBe(1) without await",
       "fix": "await expect(promise).resolves.toBe(1)",
       "why": "Since 5.0 an unawaited async assertion fails the test instead of printing a warning."
      },
      {
       "dont": "Expecting a mock to keep calls recorded in a setup file or beforeAll for later tests",
       "fix": "Record calls inside the test, or set test.clearMocks: false to get the 4.x behaviour",
       "why": "Since 5.0 clearMocks defaults to true and wipes call history before every test."
      },
      {
       "dont": "vi.mock('./some-path', () => 'hello') (Jest-style factory)",
       "fix": "vi.mock('./some-path', () => ({ default: 'hello' }))",
       "why": "In Vitest the factory returns an object with every export, including default."
      }
     ]
    }
   ]
  },
  {
   "id": "faq",
   "nav": "Questions",
   "h2": "Questions",
   "parts": [
    {
     "t": "faq",
     "items": [
      {
       "q": "Do I have to use Vite to use Vitest?",
       "a": "No. It is built for Vite projects, and the docs call it a solid alternative for projects without Vite too.",
       "evidence": {
        "url": "https://vitest.dev/guide/why",
        "quote": "Vitest aims to position itself as the test runner of choice for Vite projects, and as a solid alternative even for projects not using Vite."
       }
      },
      {
       "q": "Can I keep my Jest tests?",
       "a": "Mostly yes. Differences include no global test functions by default and a different module mock factory shape.",
       "evidence": {
        "url": "https://vitest.dev/guide/migration/jest",
        "quote": "Vitest has been designed with a Jest compatible API, in order to make the migration from Jest as simple as possible."
       }
      },
      {
       "q": "How do I fake network requests in tests?",
       "a": "The docs recommend Mock Service Worker (MSW), which intercepts requests without changes to your app code.",
       "evidence": {
        "url": "https://vitest.dev/guide/mocking/requests",
        "quote": "We recommend Mock Service Worker to accomplish this."
       }
      },
      {
       "q": "Which coverage tool does it use?",
       "a": "V8 by default, or Istanbul if you choose it; both come as optional extra packages.",
       "evidence": {
        "url": "https://vitest.dev/guide/coverage",
        "quote": "Both v8 and istanbul support are optional. By default, v8 will be used."
       }
      },
      {
       "q": "Is it maintained?",
       "a": "Yes. Version 5.1.0 was published on 2026-11-02, after the 5.0 release with its own migration guide.",
       "evidence": {
        "url": "https://registry.npmjs.org/vitest",
        "quote": "\"5.1.0\":\"2026-11-02T16:12:37.770Z\""
       }
      }
     ]
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "npm vitest"
  ],
  [
   "Category",
   "Testing"
  ],
  [
   "License",
   "MIT"
  ],
  [
   "Latest version",
   "v5.0.3, September 30, 2026"
  ],
  [
   "On GitHub since",
   "December 2021"
  ],
  [
   "Gid Score",
   "86.0"
  ],
  [
   "Rank in category",
   "#1 of 122"
  ],
  [
   "GitHub",
   "vitest-dev/vitest"
  ],
  [
   "Last change",
   "Nov 24, 2026"
  ]
 ],
 "good": [
  "Version 5 needs Node.js 22.12 or newer and Vite 6.4 or newer; older setups are not supported.",
  "By default it keeps watching files during development and runs once on a CI server.",
  "Simulated browsers (jsdom or happy-dom) are extra packages you install; tests run in plain Node.js unless you choose one."
 ],
 "checked_line": "Read by AgentGid from 16 official pages, card checked Nov 10, 2026; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/vitest-dev.png"
}