epic-testing
Guide on testing with Vitest and Playwright for Epic Stack
Install
mkdir -p .claude/skills/epic-testing && curl -L -o skill.zip "https://mcp.directory/api/skills/download/1939" && unzip -o skill.zip -d .claude/skills/epic-testing && rm skill.zipInstalls to .claude/skills/epic-testing
About this skill
Epic Stack: Testing
When to use this skill
Use this skill when you need to:
- Write unit tests for utilities and components
- Create E2E tests with Playwright
- Test forms and validation
- Test routes and loaders
- Mock external services with MSW
- Test authentication and permissions
- Configure test database
Patterns and conventions
Testing Philosophy
Following Epic Web principles:
Tests should resemble users - Write tests that mirror how real users interact with your application. Test user workflows, not implementation details. If a user would click a button, your test should click that button. If a user would see an error message, your test should check for that specific message.
Make assertions specific - Be explicit about what you're testing. Instead of vague assertions, use specific, meaningful checks that clearly communicate the expected behavior. This makes tests easier to understand and debug when they fail.
Example - Tests that resemble users:
// ✅ Good - Tests user workflow
test('User can sign up and create their first note', async ({ page, navigate }) => {
// User visits signup page
await navigate('/signup')
// User fills out form like a real person would
await page.getByRole('textbox', { name: /email/i }).fill('[email protected]')
await page.getByRole('textbox', { name: /username/i }).fill('newuser')
await page.getByRole('textbox', { name: /^password$/i }).fill('securepassword123')
await page.getByRole('textbox', { name: /confirm/i }).fill('securepassword123')
// User submits form
await page.getByRole('button', { name: /sign up/i }).click()
// User is redirected to onboarding
await expect(page).toHaveURL(/\/onboarding/)
// User creates their first note
await navigate('/notes/new')
await page.getByRole('textbox', { name: /title/i }).fill('My First Note')
await page.getByRole('textbox', { name: /content/i }).fill('This is my first note!')
await page.getByRole('button', { name: /create/i }).click()
// User sees their note
await expect(page.getByRole('heading', { name: 'My First Note' })).toBeVisible()
await expect(page.getByText('This is my first note!')).toBeVisible()
})
// ❌ Avoid - Testing implementation details
test('Signup form calls API endpoint', async ({ page }) => {
// This tests implementation, not user experience
const response = await page.request.post('/signup', { data: {...} })
expect(response.status()).toBe(200)
})
Example - Specific assertions:
// ✅ Good - Specific assertions
test('Form shows specific validation errors', async ({ page, navigate }) => {
await navigate('/signup')
await page.getByRole('button', { name: /sign up/i }).click()
// Specific error messages that users would see
await expect(page.getByText(/email is required/i)).toBeVisible()
await expect(
page.getByText(/username must be at least 3 characters/i),
).toBeVisible()
await expect(
page.getByText(/password must be at least 6 characters/i),
).toBeVisible()
})
// ❌ Avoid - Vague assertions
test('Form shows errors', async ({ page, navigate }) => {
await navigate('/signup')
await page.getByRole('button', { name: /sign up/i }).click()
// Too vague - what errors? where?
expect(page.locator('.error')).toBeVisible()
})
Two Types of Tests
Epic Stack uses two types of tests:
- Unit Tests with Vitest - Tests for individual components and utilities
- E2E Tests with Playwright - End-to-end tests of the complete flow
Unit Tests with Vitest
Basic setup:
// app/utils/my-util.test.ts
import { describe, expect, it } from 'vitest'
import { myUtil } from './my-util.ts'
describe('myUtil', () => {
it('should do something', () => {
expect(myUtil('input')).toBe('expected')
})
})
Testing con DOM:
import { describe, expect, it } from 'vitest'
import { render, screen } from '@testing-library/react'
import { MyComponent } from './my-component.tsx'
describe('MyComponent', () => {
it('should render correctly', () => {
render(<MyComponent />)
expect(screen.getByText('Hello')).toBeInTheDocument()
})
})
E2E Tests with Playwright
Basic setup:
// tests/e2e/my-feature.test.ts
import { expect, test } from '#tests/playwright-utils.ts'
test('Users can do something', async ({ page, navigate, login }) => {
const user = await login()
await navigate('/my-page')
// Interact with the page
await page.getByRole('button', { name: /Submit/i }).click()
// Verificar resultado
await expect(page).toHaveURL('/success')
})
Login Fixture
Epic Stack provides a login fixture for authenticated tests.
Use login fixture:
test('Protected route', async ({ page, navigate, login }) => {
const user = await login() // Creates user and session automatically
await navigate('/protected')
// User is authenticated
await expect(page.getByText(`Welcome ${user.username}`)).toBeVisible()
})
Login with options:
const user = await login({
username: 'testuser',
email: '[email protected]',
password: 'password123',
})
Note: The user is automatically deleted when the test completes.
Insert User without Login
To create user without authentication:
test('Public content', async ({ page, navigate, insertNewUser }) => {
const user = await insertNewUser({
username: 'publicuser',
email: '[email protected]',
})
await navigate(`/users/${user.username}`)
await expect(page.getByText(user.username)).toBeVisible()
})
Navigate Helper
Use the navigate helper to navigate with type-safety:
// Type-safe navigation
await navigate('/users/:username/notes', { username: user.username })
await navigate('/users/:username/notes/:noteId', {
username: user.username,
noteId: note.id,
})
// Also works with routes without parameters
await navigate('/login')
Test Database
Epic Stack uses a separate test database.
Automatic configuration:
- The test database is configured automatically
- It's cleaned between tests
- Data created in tests is automatically deleted
Create data in tests:
import { prisma } from '#app/utils/db.server.ts'
test('User can see notes', async ({ page, navigate, login }) => {
const user = await login()
// Create note in database
const note = await prisma.note.create({
data: {
title: 'Test Note',
content: 'Test Content',
ownerId: user.id,
},
})
await navigate('/users/:username/notes/:noteId', {
username: user.username,
noteId: note.id,
})
await expect(page.getByText('Test Note')).toBeVisible()
})
MSW (Mock Service Worker)
Epic Stack uses MSW to mock external services.
Mock example:
// tests/mocks/github.ts
import { http, HttpResponse } from 'msw'
export const handlers = [
http.get('https://api.github.com/user', () => {
return HttpResponse.json({
id: '123',
login: 'testuser',
email: '[email protected]',
})
}),
]
Use in tests: Mocks are automatically applied when MOCKS=true is
configured.
Testing Forms
Test form:
test('User can submit form', async ({ page, navigate, login }) => {
const user = await login()
await navigate('/notes/new')
// Fill form
await page.getByRole('textbox', { name: /title/i }).fill('New Note')
await page.getByRole('textbox', { name: /content/i }).fill('Note content')
// Submit
await page.getByRole('button', { name: /submit/i }).click()
// Verificar redirect
await expect(page).toHaveURL(new RegExp('/users/.*/notes/.*'))
})
Test validation:
test('Form shows validation errors', async ({ page, navigate }) => {
await navigate('/signup')
// Submit sin llenar
await page.getByRole('button', { name: /submit/i }).click()
// Verificar errores
await expect(page.getByText(/email is required/i)).toBeVisible()
})
Testing Loaders
Test loader:
// app/utils/my-util.test.ts
import { describe, expect, it } from 'vitest'
import { loader } from '../routes/my-route.ts'
import { prisma } from '../utils/db.server.ts'
describe('loader', () => {
it('should load data', async () => {
// Create data
const user = await prisma.user.create({
data: {
email: '[email protected]',
username: 'testuser',
roles: { connect: { name: 'user' } },
},
})
// Mock request
const request = new Request('http://localhost/my-route')
// Execute loader
const result = await loader({ request, params: {}, context: {} })
// Verify result
expect(result.data).toBeDefined()
})
})
Testing Actions
Test action:
// tests/e2e/notes.test.ts
test('User can create note', async ({ page, navigate, login }) => {
const user = await login()
await navigate('/users/:username/notes', { username: user.username })
await page.getByRole('link', { name: /new note/i }).click()
const formData = new FormData()
formData.set('title', 'Test Note')
formData.set('content', 'Test Content')
await page.getByRole('textbox', { name: /title/i }).fill('Test Note')
await page.getByRole('textbox', { name: /content/i }).fill('Test Content')
await page.getByRole('button', { name: /submit/i }).click()
// Verify that note was created
await expect(page.getByText('Test Note')).toBeVisible()
})
Testing Permissions
Test permissions:
test('Only owner can delete note', async ({
page,
navigate,
login,
insertNewUser,
}) => {
const owner = await login()
const otherUser = await insertNewUser()
const note = await prisma.note.create({
data: {
title: 'Test Note',
content: 'Test',
ownerId: owner.id,
},
})
// Login as other user
const session = await createSession(otherUser.id)
await page.context().addCookies([getCookie(session)])
await navigate('/users/:username/notes/:noteId', {
username: owner.username,
noteId: note.id,
})
// Verify that can't delete
await expect(page.getByRo
---
*Content truncated.*
More by epicweb-dev
View all skills by epicweb-dev →You might also like
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
ui-ux-pro-max
nextlevelbuilder
"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."
drawio-diagrams-enhanced
jgtolentino
Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
nano-banana-pro
garg-aayush
Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.
pdf-to-markdown
aliceisjustplaying
Convert entire PDF documents to clean, structured Markdown for full context loading. Use this skill when the user wants to extract ALL text from a PDF into context (not grep/search), when discussing or analyzing PDF content in full, when the user mentions "load the whole PDF", "bring the PDF into context", "read the entire PDF", or when partial extraction/grepping would miss important context. This is the preferred method for PDF text extraction over page-by-page or grep approaches.
Related MCP Servers
Browse all serversEnhance software testing with Playwright MCP: Fast, reliable browser automation, an innovative alternative to Selenium s
Supercharge browser tasks with Browser MCP—AI-driven, local browser automation for powerful, private testing. Inspired b
Playwright automates web browsers for web scraping, scraping, and internet scraping, enabling you to scrape any website
Supercharge your NextJS projects with AI-powered tools for diagnostics, upgrades, and docs. Accelerate development and b
Playwright is your browser automation studio for powerful web and visual tasks. Achieve advanced playwright testing and
Playwright enables advanced browser control for web interactions and visual testing, offering a powerful alternative to
Stay ahead of the MCP ecosystem
Get weekly updates on new skills and servers.