toolchains/javascript/testing/cypress/SKILL.md
Cypress end-to-end and component testing patterns for web apps: reliable selectors, stable waits, network stubbing, auth handling, CI parallelization, and flake reduction
npx skillsauth add bobmatnyc/claude-mpm-skills cypressInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Cypress runs browser automation with first-class network control, time-travel debugging, and a strong local dev workflow. Use it for critical path E2E tests and for component tests when browser-level rendering matters.
npm i -D cypress
npx cypress open
// cypress/e2e/health.cy.ts
describe("health", () => {
it("loads", () => {
cy.visit("/");
cy.contains("Hello").should("be.visible");
});
});
Prefer data-testid (or data-cy) attributes for selectors. Avoid brittle CSS chains and text-only selectors for critical interactions.
<button data-testid="save-user">Save</button>
cy.get('[data-testid="save-user"]').click();
Wait on app-visible conditions or network aliases rather than cy.wait(1000).
cy.intercept("GET", "/api/users/*").as("getUser");
cy.visit("/users/1");
cy.wait("@getUser");
cy.get('[data-testid="user-email"]').should("not.be.empty");
cy.interceptStub responses for deterministic tests and speed. Keep a small set of “real backend” smoke tests separate.
cy.intercept("GET", "/api/users/1", {
statusCode: 200,
body: { id: "1", email: "[email protected]" },
}).as("getUser");
Prefer cy.session to cache login for speed and stability.
// cypress/support/commands.ts
Cypress.Commands.add("login", () => {
cy.session("user", () => {
cy.request("POST", "/api/auth/login", {
email: "[email protected]",
password: "password",
});
});
});
// e2e spec
beforeEach(() => {
cy.login();
});
Run component tests to validate UI behavior in isolation while keeping browser rendering.
npx cypress open --component
// cypress/component/Button.cy.tsx
import React from "react";
import Button from "../../src/Button";
describe("<Button />", () => {
it("clicks", () => {
cy.mount(<Button onClick={cy.stub().as("onClick")}>Save</Button>);
cy.contains("Save").click();
cy.get("@onClick").should("have.been.calledOnce");
});
});
Store artifacts for failed runs and keep videos optional to reduce storage.
// cypress.config.ts
import { defineConfig } from "cypress";
export default defineConfig({
video: false,
screenshotOnRunFailure: true,
retries: { runMode: 2, openMode: 0 },
});
Parallelize long E2E suites via Cypress Cloud when runtime dominates feedback loops.
cy.wait(1000) as a synchronization mechanism.cy.session and per-test setup.Actions:
data-testid hook for the element.should("be.visible")).Actions:
tools
Xquik X data automation API - Use REST or MCP for tweet search, user lookup, follower exports, media downloads, monitors, webhooks, giveaway draws, and confirmation-gated X actions.
tools
LinkedIn automation via the Linked API CLI - fetch profiles, search people and companies, send messages, manage connections, create posts, react, comment, and run Sales Navigator and custom workflows. Use when the user wants to interact with LinkedIn.
tools
MCP (Model Context Protocol) server build and evaluation guide, including local conventions for tool surfaces, config, and testing
tools
MCP (Model Context Protocol) - Build AI-native servers with tools, resources, and prompts. TypeScript/Python SDKs for Claude Desktop integration.