Frontend Testing

Frontend Testing

Teaches an AI coding agent to build frontend test suites with Jest, Vitest, React Testing Library and Cypress, with reference guides, a scaffold script and a template.

Skill files8 files

references/

scripts/

templates/

SKILL.md91 lines
1
---
2
name: frontend-testing
3
description: >
4
Implement comprehensive frontend testing using Jest, Vitest, React Testing
5
Library, and Cypress. Use when building robust test suites for UI and
6
integration tests.
7
---
8
9
# Frontend Testing
10
11
## Table of Contents
12
13
- [Overview](#overview)
14
- [When to Use](#when-to-use)
15
- [Quick Start](#quick-start)
16
- [Reference Guides](#reference-guides)
17
- [Best Practices](#best-practices)
18
19
## Overview
20
21
Build comprehensive test suites for frontend applications including unit tests, integration tests, and end-to-end tests with proper coverage and assertions.
22
23
## When to Use
24
25
- Component testing
26
- Integration testing
27
- End-to-end testing
28
- Regression prevention
29
- Quality assurance
30
- Test-driven development
31
32
## Quick Start
33
34
Minimal working example:
35
36
```typescript
37
// Button.test.tsx
38
import { render, screen, fireEvent } from '@testing-library/react';
39
import '@testing-library/jest-dom';
40
import { Button } from './Button';
41
42
describe('Button Component', () => {
43
it('renders button with text', () => {
44
render(<Button>Click me</Button>);
45
expect(screen.getByRole('button')).toHaveTextContent('Click me');
46
});
47
48
it('calls onClick handler when clicked', () => {
49
const handleClick = jest.fn();
50
render(<Button onClick={handleClick}>Click</Button>);
51
52
fireEvent.click(screen.getByRole('button'));
53
expect(handleClick).toHaveBeenCalledTimes(1);
54
});
55
56
it('disables button when disabled prop is true', () => {
57
render(<Button disabled>Click me</Button>);
58
expect(screen.getByRole('button')).toBeDisabled();
59
});
60
61
it('applies variant styles correctly', () => {
62
// ... (see reference guides for full implementation)
63
```
64
65
## Reference Guides
66
67
Detailed implementations in the `references/` directory:
68
69
| Guide | Contents |
70
|---|---|
71
| [Jest Unit Testing (React)](references/jest-unit-testing-react.md) | Jest Unit Testing (React) |
72
| [React Testing Library Integration Tests](references/react-testing-library-integration-tests.md) | React Testing Library Integration Tests |
73
| [Vitest for Vue Testing](references/vitest-for-vue-testing.md) | Vitest for Vue Testing |
74
| [Cypress E2E Testing](references/cypress-e2e-testing.md) | Cypress E2E Testing |
75
| [Test Coverage Configuration](references/test-coverage-configuration.md) | Test Coverage Configuration |
76
77
## Best Practices
78
79
### ✅ DO
80
81
- Follow established patterns and conventions
82
- Write clean, maintainable code
83
- Add appropriate documentation
84
- Test thoroughly before deploying
85
86
### ❌ DON'T
87
88
- Skip testing or validation
89
- Ignore error handling
90
- Hard-code configuration values
91

© AJ Geddes · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 6,373 prompts

More by @OpenSourceBuffGuy

See all
Website Clone Architect prompt image

Website Clone Architect

Reverse-engineers a website section by section, writes component specs, and hands them to parallel builder agents in git worktrees to rebuild it.

agent-skill, orchestrator, parallel-agents, multi-agent, plan-then-execute, web-development, frontend, codebase-analysis, scaffolding, css, html, nextjs, typescript, git, mcp, claude-code, for-developers, for-designers, long-form, advanced, technical-spec, task-decomposition, structured-output, design-systems, ui-ux, tool-use, checklist, report, vibe-coding

Italian Terrace Cafe Candid Portrait prompt image

Italian Terrace Cafe Candid Portrait

Generates a photorealistic candid shot of a woman in a white corset dress laughing at a sunny hotel terrace cafe, written as detailed JSON.

image-prompt, json-prompt, structured-output, photorealistic, portrait, woman, candid, fashion, cottagecore, natural-light, golden-hour, bokeh, summer, travel, cityscape, mountains, medium-shot, vibrant-colors, for-photographers, nano-banana, fashion-shoot, luxury

Night Street Photo With Leashed Cat prompt image

Night Street Photo With Leashed Cat

Generates a flash-lit night street photo of a blonde woman in a retro track jacket walking a hissing tabby cat on a leash.

image-prompt, json-prompt, nano-banana, structured-output, portrait, woman, animals, pet-portrait, night-scene, street-photography, candid, editorial, fashion, dramatic-lighting, photorealistic, vertical-format, medium-shot, graffiti, for-photographers, for-content-creators

1 view

Reviews

Loading reviews…

Discussion

Loading comments…