xforge-testing

Guides writing Vitest 5 component tests and Playwright e2e tests for this monorepo.

Updated Sep 5, 2026
One-click install
npx skills add https://github.com/pohlai88/afenda-xforge-v5 --skill xforge-testing-pohlai88
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: xforge-testing
Source: https://github.com/pohlai88/afenda-xforge-v5/tree/main/.claude/skills/xforge-testing
Command: npx skills add https://github.com/pohlai88/afenda-xforge-v5 --skill xforge-testing-pohlai88

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Published testing guidance targets Vitest 3 and React 18, but this repository runs Vitest 5 on Vite 8 with React 19, so recalled knowledge produces wrong configs, wrong imports, and misdiagnosed failures. This Skill encodes the verified, measured testing rules for the repo. ## Core Features & Use Cases - Runner selection: Routes work between Vitest (component tests in tests/**/*.test.{ts,tsx}) and Playwright (browser tests in e2e/**/*.e2e.ts), explaining why the .e2e.ts suffix must be kept. - Query and interaction discipline: Enforces Testing Library's role-first query priority and user-event over fireEvent under React 19. - Environment troubleshooting: Diagnoses false e2e failures caused by reuseExistingServer pointing Playwright at a stale server on the wrong port. - Use Case: When adding a test for a new design-system component, follow the Skill to place it next to the component, query with getByRole, interact via userEvent.setup(), and mock server actions with vi.hoisted. ## Quick Start Ask the assistant to write a component test for a button in packages/design following the xforge-testing rules.

Frequently Asked Questions about xforge-testing

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

FAQPage Schema
How do I choose between Vitest and Playwright for a test?

Use Vitest for a component's rendered output, props, variants, and accessibility roles, placed next to the component. Use Playwright only for real-browser concerns like navigation, server responses, layout, and focus across a page, since it is roughly 100x slower.

How do I test user interactions with React Testing Library?

Use @testing-library/user-event instead of fireEvent. Call userEvent.setup() before render, then await each method such as user.click(screen.getByRole("button")). Under React 19 with RTL 16, act is handled automatically.

Do I need vite-tsconfig-paths with Vitest 5 and Vite 8?

No. Vite 8 supports resolve.tsconfigPaths natively, which makes imports like @/app/page resolve under test. Adding the vite-tsconfig-paths plugin is a mistaken re-addition, not missing wiring.

Why does my Playwright test fail with element not found locally?

The reuseExistingServer option points the suite at whatever already listens on the e2e port, which may be a stale server serving a different app. Check the port with curl or netstat before believing the failure; the app itself is usually healthy.

Should I use getByTestId or getByRole in Testing Library?

Prefer getByRole first, since it asserts the accessibility tree, followed by getByLabelText and getByText. getByTestId is a last-resort escape hatch that requires a justifying comment, and container.querySelector should be avoided entirely.

How do I mock server actions in Vitest component tests?

Mock the @/features/<domain>/actions module because server actions import server-only code that throws under jsdom. Declare mock functions inside vi.hoisted(() => ({...})), since a plain const is in its temporal dead zone when the hoisted factory runs.