All Prompts
intermediate
Cypress Component Test Suite
Generate isolated Cypress component tests covering rendering, interactions, loading/error states, keyboard accessibility, and ARIA semantics — with the full cypress.config.ts setup.
Prompt Template
You are a senior frontend SDET specialising in Cypress component testing.
Component: {{componentName}}
File path: {{componentPath}}
Props interface: {{propsInterface}}
State management: {{stateManagement}} (Context / Redux / Zustand / none)
Design system: {{designSystem}} (Tailwind / MUI / Chakra / none)
Generate a complete Cypress component test suite covering:
1. **Default render** — mounts with default props, no console errors, matches snapshot
2. **Prop variants** — one test per meaningful prop combination (required vs optional, edge values)
3. **User interactions** — click, type, select, hover trigger correct callbacks (cy.spy assertions)
4. **Loading state** — skeleton/spinner renders while data is pending
5. **Success state** — correct data renders after async resolution (cy.intercept stub)
6. **Error state** — error UI renders with correct message on rejection
7. **Empty state** — zero-length data shows correct empty message/CTA
8. **Keyboard navigation** — Tab moves focus correctly, Enter/Space activate, Escape closes modals
9. **ARIA semantics** — correct roles, aria-labels, aria-expanded, aria-live regions
10. **Mobile viewport** — component in 375px viewport has no overflow, touch targets ≥ 44 × 44px
11. **Dark mode** — if design system supports it, dark mode class renders correct colour tokens
12. **Ref forwarding** — if applicable, ref points to the correct DOM element
**Supporting setup:**
- `cypress.config.ts` with component testing configured for {{framework}} (Vite/Webpack)
- `cypress/support/component.ts` with global mounts, custom commands
- `cypress/support/commands.ts` — add cy.mockApiResponse() helper
**Constraints:**
- Mount in isolation — stub all API calls with cy.intercept
- Use cy.findByRole() (Testing Library plugin) over cy.get('[data-testid]') for semantic queries
- Assert computed styles only for critical visual properties
- Take cy.screenshot() at end of each state test for visual recordTags
cypress
component-testing
react
accessibility
isolation
How to use this prompt
- 1Copy the prompt template using the Copy button above.
- 2Open your preferred AI assistant (ChatGPT, Claude, Gemini, Copilot, etc.).
- 3Paste the prompt and replace the {{placeholder}} variables with your project-specific values.
- 4Review the output - treat it as a professional first draft, not a final deliverable.
- 5Iterate: refine the output by asking follow-up questions or providing more context.
Frequently asked questions
Which AI models work best with this prompt?v
This prompt works with any capable language model including ChatGPT (GPT-4o), Claude (3.5+), Gemini (1.5 Pro+), and GitHub Copilot Chat. More capable models produce more complete and accurate outputs.
How do I adapt the prompt for a different framework?v
Replace the framework placeholder with your target framework and update any framework-specific syntax references in the output. The structure and logic of the generated tests will transfer across frameworks.
Can I use this prompt commercially?v
Yes. All prompts on QATraining.uk are free to use for personal and commercial QA work. Attribution is appreciated but not required.