Cypress / Quiz
Custom Commands: Build Your Arsenal
Cypress.Commands.add turns copy-paste into an API. Know where commands live, how to type them, and when a plain function beats a command.
- Difficulty
- Easy
- Format
- Quiz
- Points
- 100
- Estimate
- 9 min
// MISSION BRIEF
Your Mission
Every mature Cypress suite grows a command vocabulary: cy.login, cy.seedCart, cy.dismissBanner. Done right, specs read like intent. Done wrong, you get a junk drawer nobody can type-check.
Six questions on building, overriding, and typing custom commands. Speed bonus active.
// FIRST CONTACT
Battle teaser
Where do custom commands conventionally live so every spec gets them?
- AIn node_modules/cypress/commands.js
- BIn every spec file that needs them, re-declared each time
- CIn cypress.config.ts inside setupNodeEvents
- DIn cypress/support/commands.ts, imported by the support file that Cypress loads before each spec
Answers, scoring, hints, and the full battle stay sealed.
// SKILL TAGS
cypressjavascripttest-architectureweb