Testing Test Writing

Guide Vitest unit and Playwright end-to-end test creation with coding standards.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/SpacePlushy/portfolio --skill testing-test-writing-spaceplushy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Testing Test Writing
Source: https://github.com/SpacePlushy/portfolio/tree/main/.claude/skills/testing-test-writing
Command: npx skills add https://github.com/SpacePlushy/portfolio --skill testing-test-writing-spaceplushy

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Inadequate or poorly written tests lead to undetected bugs, fragile code, and a lack of confidence in deployments. This skill guides AI in writing strategic, behavior-focused tests for critical functionality using Vitest for unit tests and Playwright for E2E, giving you confidence in your code.

Core Features & Use Cases

  • Strategic Test Coverage: Directs AI on writing unit tests with Vitest and end-to-end tests with Playwright for core user flows.
  • Behavior-Driven Testing: Guides AI to focus tests on expected outcomes rather than implementation details, using mocks effectively.
  • Comprehensive Testing: Ensures AI tests API routes, Content Collections, and integrates with testing libraries like React Testing Library.

Quick Start

Write a Playwright E2E test for the user login flow, ensuring successful login and redirection to the dashboard.

Frequently Asked Questions about Testing Test Writing

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

FAQPage Schema
How do I write unit tests with Vitest that focus on behavior instead of implementation?

Behavior-focused unit tests with Vitest verify expected outcomes rather than internal implementation details. Write tests that describe what your code should do—like testing a login function returns a user token—using mocks to isolate external dependencies. This approach catches real bugs while keeping tests maintainable as your code evolves.

What's the best way to set up Playwright end-to-end tests for critical user flows?

Playwright E2E tests automate user interactions across your full application stack. Start by identifying core flows—like user login and dashboard navigation—then write tests that simulate these exact steps in a real browser. Configure your test setup files and environment to run consistently, and organize tests by user journey rather than by page.

Can I use Vitest and Playwright together in the same project?

Yes. Vitest handles unit and component tests with React Testing Library, while Playwright covers end-to-end scenarios. Both integrate into a single testing strategy: Vitest validates logic and component behavior in isolation, Playwright confirms workflows across your full application. Configure both in your project's test setup and naming conventions.

How do I test API routes and Content Collections with effective coverage?

Test API routes and Content Collections by writing unit tests that verify request handling, data validation, and response structure. Use mocks for external dependencies and database calls. Define coverage metrics upfront to ensure tests exercise core user flows and critical functionality paths, not just happy-path scenarios.

What naming conventions and file structure should I follow for test files?

Use consistent naming—.test.ts or .spec.ts extensions for Vitest, descriptive names for Playwright suites—and organize files alongside source code or in a dedicated test directory. Include test configuration files like vitest.config.ts and test setup utilities. Clear naming and structure make tests discoverable, maintainable, and easier to run.

Why do poorly written tests fail to catch bugs and break during refactoring?

Tests that couple to implementation details rather than behavior fail when code changes, even if functionality remains intact. They also miss real bugs because they don't verify expected outcomes. Behavior-focused testing with strategic coverage of critical flows ensures tests catch genuine issues and remain stable through refactors.