vitest-testing

Configure Vitest for unit and end-to-end testing in NestJS projects.

Updated Dec 26, 2025
One-click install
npx skills add https://github.com/JoyanLabs/template-nestjs-dashboard-better_auth --skill vitest-testing-joyanlabs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vitest-testing
Source: https://github.com/JoyanLabs/template-nestjs-dashboard-better_auth/tree/main/skills/vitest-testing
Command: npx skills add https://github.com/JoyanLabs/template-nestjs-dashboard-better_auth --skill vitest-testing-joyanlabs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Vitest-based testing patterns for NestJS projects, enabling consistent unit and end-to-end tests and a clear testing workflow.

Core Features & Use Cases

  • Unit & E2E Testing: Standard patterns for unit tests of services, controllers, and handlers, and end-to-end tests for controllers.
  • Mocking Utilities: Guidance and examples using vitest-mock-extended to mock dependencies.
  • Test Environment & Structure: Clear test directory structure and environment setup for NestJS apps.

Quick Start

Run Vitest tests in your NestJS project using the configured test scripts and environment.

Frequently Asked Questions about vitest-testing

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

FAQPage Schema
How do I set up Vitest in a NestJS project for unit and e2e testing?

Vitest provides standard patterns for unit and e2e testing in NestJS, enabling consistent tests for services, controllers, and handlers while applying a clear testing workflow and environment setup.

What's the best way to mock dependencies in NestJS using Vitest?

The best way to mock dependencies in NestJS is using vitest-mock-extended utilities, which provide structured guidance and examples for creating mocks within your Vitest test environment.

Does Vitest work with NestJS for end-to-end controller testing?

Yes, Vitest works with NestJS by providing standard end-to-end testing patterns specifically designed for controllers, alongside unit tests for services and handlers within a structured test directory.

Do I need pnpm to run Vitest tests in a NestJS codebase?

You need pnpm to run Vitest tests in a NestJS codebase because the testing workflow requires integration with pnpm scripts to execute the configured test commands and environment setup.

How does the Vitest test directory structure work in NestJS applications?

The Vitest test directory structure works by providing a clear environment setup for NestJS apps, organizing unit tests for services and controllers alongside end-to-end tests in a standardized layout.