vitest-monorepo-setup

Configure Vitest test infrastructure for npm and Bun workspace monorepos.

Updated Jul 7, 2026
One-click install
npx skills add https://github.com/TitoPrausee/nexus-toti --skill vitest-monorepo-setup
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vitest-monorepo-setup
Source: https://github.com/TitoPrausee/nexus-toti/tree/main/data/skills/software-development/vitest-monorepo-setup
Command: npx skills add https://github.com/TitoPrausee/nexus-toti --skill vitest-monorepo-setup

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill removes the friction of adding reliable Vitest testing to npm and Bun workspace monorepos, especially when multiple packages, shared libraries, and web apps need one consistent test setup.

Core Features & Use Cases

  • Workspace-wide setup: Installs and aligns Vitest at the repository root so packages share the same test runner version.
  • Web app support: Configures React and Next.js packages with jsdom, Testing Library, and a browser-friendly setup file.
  • Monorepo troubleshooting: Fixes common issues like import resolution failures, wrong relative paths from tests folders, and version mismatch errors.
  • Use case: A team can add tests to a shared package and a web frontend without creating conflicting local Vitest installs or broken test paths.

Quick Start

Ask me to set up Vitest for your workspace monorepo and include your package layout, framework, and any test path or jsdom requirements.

Frequently Asked Questions about vitest-monorepo-setup

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up Vitest across an npm or Bun workspace monorepo?

To set up Vitest across a monorepo, install the test runner at the repository root to align versions, configure per-package test scripts, and apply workspace-aware include patterns for shared libraries and web apps.

Why does Vitest fail to resolve imports from __tests__ folders in my monorepo?

Vitest import resolution failures in monorepos often stem from incorrect relative paths in __tests__ folders or version mismatches between local installs. Aligning the root-level configuration and fixing relative paths resolves these issues.

Can I configure Vitest with jsdom and Testing Library for Next.js packages in a monorepo?

Yes, you can configure Vitest for Next.js packages by setting up jsdom and Testing Library in a browser-friendly setup file. This ensures proper path resolution and supports localized assertions for web frontend testing.

Do I need a root-level Vitest installation for a monorepo or can I install it per package?

A root-level Vitest installation is required for monorepos to ensure all packages share the same test runner version. Installing it per package risks creating conflicting local installs and broken test paths across shared libraries.

What is the best way to troubleshoot Vitest version mismatch errors in a monorepo?

The best way to fix Vitest version mismatch errors is to consolidate the installation at the workspace root. This aligns the test runner version across shared libraries, React web apps, and API packages, eliminating conflicts.

Does Vitest work with both npm and Bun workspace monorepos?

Yes, Vitest works with both npm and Bun workspace monorepos. It configures test infrastructure for shared libraries, React or Next.js web packages, and API packages using jsdom and Testing Library consistently.