cypress-web-e2e

Use when a web app has or needs Cypress end-to-end tests: config, sign-in with cy.session and cy.origin, CI without Cypress Cloud, JUnit gate, flaky specs, or choosing between Cypress and Playwright.

Qu'est-ce que cypress-web-e2e ?

cypress-web-e2e is a Claude Code agent skill that use when a web app has or needs Cypress end-to-end tests: config, sign-in with cy.session and cy.origin, CI without Cypress Cloud, JUnit gate, flaky specs, or choosing between Cypress and Playwright.

Compatible avec✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/kaybarax/engineering-department-skills/tree/HEAD/skills/cypress-web-e2e

Installed? Explore more Développement et programmation skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

Demander à votre IA préférée

Ouvre une nouvelle conversation avec cette compétence d'agent déjà préchargée.

Documentation

Cypress Web End-to-End Testing

Purpose & When to Use

Run a few critical browser journeys with Cypress on the same gates as playwright-web-e2e. Playwright is the default for a new project; cypress-or-playwright.md decides. Logic belongs in unit tests, service shapes in contract-testing, WCAG checks in accessibility-testing, unstable tests in flaky-test-management. Cypress component testing and Cypress Cloud are out of scope.

Architecture & Design Pattern Mandate

Mandatory companion: software-engineering-architecture-patterns. Tell the user which patterns you apply and why.

  • Plug-in runner behind verify.d. The project owns how the app starts (E2E_SERVER_COMMAND), when it is ready (/health/ready) and how a user signs in (/login, /api/v1/auth/*, AUTH_REDIRECT_URI, e2e/oidc.sh), and the target is E2E_BASE_URL for both runners. Cypress only consumes these, so Playwright can replace it, or run beside it during a migration, without a change to the app or CI.
  • Neutral report as the interface. Cypress writes JUnit; check-tests.mjs judges it.
  • Hermetic tests. Each test creates its own data and runs alone or in any order.
  • Considered: Playwright (default); both at once (only during a migration, because two runners cost two sets of upgrades).

Working Rules

These apply to every step below. Full version: agent-working-agreement.

  1. Look it up. Take versions, flags, API names, config keys and addresses from current official docs or the installed tool's --help, never from memory. Cannot confirm it? Say so.
  2. Read before writing. Detect the package manager, conventions and existing files first. Never overwrite an existing file without showing the diff.
  3. Stop for a yes before anything destructive, costly, public, or aimed at a shared or production system. Show the exact command and target first.
  4. Prove it. Report the command, its exit code and the relevant output. "No tests found" is a failure.
  5. When a check fails, fix the cause or stop and report. Never skip, delete, weaken or quarantine a test, lower a threshold, or bypass a hook to get a pass.
  6. Undo only your own changes. Never use git checkout -- ., git reset --hard or git clean as rollback.
  7. Use the shared contract in engineering-contract for ports, health paths, env names, auth, errors and file ownership. Read engineering-manifest.json first if present and record what you did in it.
  8. Apply the principles in software-engineering-principles to code you write or review: correct and safe first, then the simplest thing that meets the requirement (KISS, YAGNI), then SOLID and DRY where a concrete cost justifies them.

Topology & Execution Mode

  • Standalone (default): cypress.config.ts and cypress/ at the root. Several services or monorepo: in the web app's package or in an e2e/ package of its own; scripts/ stays at the root. The gate runs every package that has a cypress.config.ts and fails if a package has *.cy.ts files without one.
  • Greenfield: full path below. Brownfield: gate beside what exists, then one change at a time.

Handoff Contract

  • Consumes: a start command, /health/ready, /login and /api/v1/auth/* (identity-provider-auth-contract), scripts/each-package.mjs, scripts/check-tests.mjs and scripts/test-integrity.mjs from vitest-jest-unit-integration-testing.
  • Produces: cypress.config.ts, cypress/**, scripts/cypress-run.mjs, scripts/merge-junit.mjs, scripts/verify.d/75-e2e-cypress.sh, reports/e2e-cypress.xml.
  • Next Recommended Skills: github-actions-ci-cd, accessibility-testing, flaky-test-management.

Prerequisites & Latest-Version Check

  • npm view cypress version engines; checked 2026-11-29: 16.4.0, Node ^22 || ^24 || >=26. Works with TypeScript 6.0.3 and 7.0.2.
  • Chrome on the machine (GitHub's Ubuntu runners have it), or a cypress/included:<version> image, which exists for amd64 and arm64. About 530 MB for the binary on macOS. Docker for e2e/oidc.sh.
  • Set both before the first install: CYPRESS_CRASH_REPORTS=0 (no exception reports) and CYPRESS_COMMERCIAL_RECOMMENDATIONS=0 (no Cloud promotion in logs).

Inputs to Confirm

  1. Cypress or Playwright, by the reference. Journeys that must work, written down before the specs.
  2. Browser: Chrome by default. Electron is deprecated; WebKit is experimental and has no cy.origin(), so the sign-in here cannot run on it.
  3. Target: local app (default) or a deployed URL. Only *.smoke.cy.ts specs run against a shared or production URL.
  4. Sign-in method; for an external target a dedicated test user, never a real person's account.

Step-by-Step Procedure

Greenfield Path

  1. Apply the decision rule and record it: manifest.mjs record decision web-e2e-runner --title "Cypress for web end-to-end tests" --status accepted --alternatives "Playwright" (engineering-contract).
  2. Export the two variables above. Install cypress as an exact dev dependency, plus typescript and @types/node if missing. --ignore-scripts skips the binary, and pnpm 11 stops with ERR_PNPM_IGNORED_BUILDS until pnpm-workspace.yaml says allowBuilds: { cypress: false } (or true). Then run npx --no-install cypress install and npx --no-install cypress verify.
  3. Copy cypress.config.ts and assets/cypress/ (tsconfig.json, support/, the smoke spec) and replace the heading placeholder. Its own tsconfig.json keeps Cypress globals apart from Vitest's or Jest's; exclude cypress/ from the app's. Add cypress.config.ts to the root tsconfig.json include, or ESLint's project service does not find it. Add cypress/screenshots, cypress/videos, cypress/downloads and reports/ to .gitignore.
  4. Sign-in: copy oidc.sh to e2e/ unless it is already there. It is the same file as in playwright-web-e2e: a pinned Keycloak on loopback port 3018 with exactly this run's user; it refuses any APP_ENV but local/test. Stop it with APP_ENV=test bash e2e/oidc.sh down. cy.signIn() then uses cy.session (setup through /login and the provider's own form in cy.origin, validation by /api/v1/auth/me, reused across specs). Auth module on another origin than the app (single-page app and gateway): set AUTH_REDIRECT_URI (engineering-contract) to its callback, same host name as the app, for example http://127.0.0.1:4000/api/v1/auth/callback; oidc.sh and signIn follow it, as Playwright does. E2E_SERVER_COMMAND starts both with CORS_ALLOWED_ORIGINS set to the app. Run with one and with two loopback origins against Keycloak; two host names are not verified. An app without sign-in: leave out oidc.sh, commands.ts and its import.
  5. Copy cypress-run.mjs and merge-junit.mjs to scripts/, 75-e2e-cypress.sh to scripts/verify.d/, and the gates if missing (vitest-jest-unit-integration-testing steps 3 and 4, with each-package.mjs). Cypress has no webServer option; cypress-run.mjs starts the app through oidc.sh, waits for /health/ready (E2E_READY_PATH names another path; an HTML page, such as a single-page fallback, is not readiness), runs Chrome, joins the reports and stops only what it started. Several processes or migrations: put them into a script and set E2E_SERVER_COMMAND="bash <script>".
  6. Write each journey test-first in cypress/e2e/<journey>.cy.ts: cy.signIn(), then cy.visit(). Select by role or label text (cy.contains('button', 'Save'), cy.contains('label', 'Name')) or data-testid; no CSS chains, no XPath. Assert with .should(), never cy.wait(<number>). Every test needs an assertion on the result.
  7. Record the count: node scripts/check-tests.mjs --suite e2e-cypress --junit reports/e2e-cypress.xml --write, then commit quality-baseline.json.

Brownfield Path

  1. Discover (read-only):
    git ls-files | grep -iE 'cypress|\.cy\.[jt]sx?$|playwright' | head -50
    git grep -nE 'cy\.wait\([0-9]|\.(only|skip)\(|Cypress\.env\(|cy\.(exec|end|prompt)\(|retries|force: *true|specPattern' -- '*.ts' '*.tsx' '*.js'
    git grep -nE -e '--record|CYPRESS_RECORD_KEY|--pass-with-no-tests|cypress-io/github-action' -- .github package.json '*.yml'
    node -p "require('cypress/package.json').version"
    
  2. Run the existing suite twice; record passes, failures and duration. Hide nothing.
  3. Report: version gap, removed calls in use (Cypress.env(), cy.exec(), cy.end() are gone in 16), Cypress Cloud use with its cost and what it uploads, specs without assertions, retries above 0. Show the plan and wait.
  4. Add the gate beside what exists: the JUnit reporter lines of cypress.config.ts with includePending: true, its excludeSpecPattern for quarantined specs, the two scripts, 75-e2e-cypress.sh, and a baseline at today's count. The baseline needs a run without failed or pending tests: until then keep 75-e2e-cypress.sh out and follow brownfield step 4 of vitest-jest-unit-integration-testing. Cypress 13 works (run on 13.17.0): cypress-run.mjs leaves out --posix-exit-codes where cypress run --help does not list it. Leave spec names and an existing sign-in alone. The gate looks for cypress.config.ts and *.cy.ts; a JavaScript project changes these two names in its copy.
  5. Set retries: 0. A test that now fails was already unstable: fix it or use flaky-test-management.
  6. Upgrade one major at a time with the changelog; each needs a yes. Secrets move from Cypress.env() to cy.env(), public values to expose.

Everyday Work

  • A UI change breaks a test: fix the selector if the element moved; change an assertion only if the requirement changed, and say which.
  • Debug a failure: cypress/screenshots/, or against a running app E2E_BASE_URL=http://127.0.0.1:3000 npx cypress open. There is no trace viewer without Cloud.
  • Debug a flaky spec: repeat it on its own, 10 times, with node scripts/cypress-run.mjs --spec cypress/e2e/<name>.cy.ts. A temporary retries: { experimentalStrategy: 'detect-flake-but-always-fail', experimentalOptions: { maxRetries: 2, stopIfAnyPassed: true }, openMode: false, runMode: true } shows whether a retry passes and still fails the run (checked on 16.4.0). Plain retries: 1 and detect-flake-and-pass-on-threshold turn a flaky test green: do not use them.
  • Quarantined specs are named *.quarantined.cy.ts; only E2E_QUARANTINED=1 node scripts/cypress-run.mjs runs them; the gate ignores that variable.
  • Smoke after a deploy: E2E_BASE_URL=https://… node scripts/cypress-run.mjs runs the smoke specs only.
  • cypress-run.mjs accepts --spec, --browser and a few display flags, and hides CYPRESS_* variables from Cypress. Other settings go into cypress.config.ts, where they are reviewed.

Approval Stops

Wait for a yes before: any other spec against a shared or production URL, Cypress Cloud, --record or cy.prompt (name the cost and that data leaves the project), a major upgrade, quarantining or removing a test, lowering the baseline, moving to another runner.

Owned Files & Environment Contract

  • Owned: cypress.config.ts, cypress/**, scripts/cypress-run.mjs, scripts/merge-junit.mjs, scripts/verify.d/75-e2e-cypress.sh. e2e/oidc.sh is shared with playwright-web-e2e; whichever skill came first owns it, and both ship the same file.
  • .env.example block: E2E_BASE_URL= (CYPRESS_BASE_URL still works; both set to different values is refused), E2E_TEST_USER_EMAIL=, E2E_TEST_USER_PASSWORD= (both only for an external target, otherwise generated), E2E_SERVER_COMMAND= (default node --run start), E2E_READY_PATH= (default /health/ready). Optional for oidc.sh: E2E_OIDC_PORT, E2E_OIDC_NAME, E2E_OIDC_AUDIENCE, E2E_OIDC_ROLES, E2E_OIDC_TENANT. Keep one entry per name if playwright-web-e2e added it.
  • Secrets: never in cypress.config.ts, expose, cypress.env.json or a command line. Read them with cy.env(), type them with { log: false }. A failed cy.request() prints its headers, session cookies included, into the report: use failOnStatusCode: false and assert the status. Screenshots can show personal data; keep CI artifacts private and short-lived.

Verification & Smoke Tests

npx tsc --noEmit -p cypress
node scripts/test-integrity.mjs              # exit 1 after adding it.only to a .cy.ts file
bash scripts/verify.d/75-e2e-cypress.sh      # exit 0 and a line "OK e2e-cypress: ..."
node scripts/cypress-run.mjs --spec 'cypress/e2e/**/*.smoke.cy.ts'   # exit 0
node scripts/cypress-run.mjs --spec 'cypress/e2e/**/*.none.cy.ts'    # exit 1, "no spec files were found"

After changing a script, run its tests from the skill folder: node --test scripts/merge-junit.test.mjs scripts/cypress-run.test.mjs.

Break things on purpose and show each failure, then undo: rename the page heading (smoke spec fails); delete one spec (below the baseline); it.skip (skipped test); exit the app during the run (the app exited during the run, no process left).

Common Failure Modes & Rollback

  • Cypress binary is missing: the package manager skipped the install script. npx --no-install cypress install, then verify.
  • Exit code 5 read as "unknown error": without --posix-exit-codes the code is the number of failed tests.
  • Only the last spec is in the report: mochaFile has no [hash]; each spec overwrote the one before.
  • is not well-formed XML or reports failures=... but shows ...: the reporter was cut off or another tool wrote into reports/cypress. Do not edit the report; rerun.
  • Skipped tests are not reported: includePending is missing. merge-junit.mjs still adds them from the totals.
  • Electron ... deprecated in the output: no browser was named. Use cypress-run.mjs or --browser chrome.
  • Cypress.env() ... removed: use cy.env().
  • Error about a different origin during sign-in: the provider's page is handled outside cy.origin(). Only functions defined inside its callback can be used there.
  • Sign-in stops at the provider's form: its labels differ; change them in commands.ts. invalid redirect_uri: the app's address is not http://127.0.0.1:$PORT; set PUBLIC_BASE_URL; or the callback is on another origin, set AUTH_REDIRECT_URI.
  • not ready after ... s: read reports/e2e-cypress-server.log; /health/ready is not 200, or answers with an HTML page.
  • is not accepted or not passed to Cypress: put the setting into cypress.config.ts.
  • port ... is already in use: stop that app or set PORT. A running app does not know this run's user.
  • Parallel runs on one Linux machine fail to start: they can collide on one Xvfb display. Start one Xvfb and set DISPLAY for all, or run one after the other.
  • Rollback: revert the owned paths from the restore point; remove the dev dependency and APP_ENV=test bash e2e/oidc.sh down. Leave e2e/oidc.sh if Playwright uses it. A flaky test stays blocking until fixed, or quarantined with approval.

Skills associés