Cypress Test Bootstrap
Purpose
Scaffold a production-ready Cypress project or generate structured test files following best practices — organized for maintainability and QA team reuse.
Input Accepted
- Request to init a new Cypress project from scratch
- Feature name or module to add tests for
- User Story or Gherkin scenarios to automate
- API endpoint to test via
cy.request() - Existing test suite to extend
Project Structure (Full Bootstrap)
[project-name]/
├── cypress.config.js
├── package.json
├── .env.example
├── .gitignore
└── cypress/
├── e2e/ ← test specs by feature/module
│ └── [module]/
│ └── [feature].cy.js
├── fixtures/ ← test data (JSON files)
│ ├── users.json
│ └── transactions.json
├── support/
│ ├── e2e.js ← global setup / imports
│ ├── commands.js ← custom reusable commands
│ └── api-helpers.js ← API utility functions
└── pages/ ← Page Object Model
└── [FeatureName]Page.js
Generation Process
Full Project Bootstrap — generates:
cypress.config.js— config with env variablespackage.json— dependencies and run scripts.env.example— environment variable template.gitignore— excludes artifacts, credentials, node_modulescypress/support/commands.js— login + apiRequest custom commandscypress/support/e2e.js— global importscypress/fixtures/users.json— test data structure- Sample transfer spec file ready to adapt to the target feature
Single Spec File — generates:
describeblock for the featurebeforeEachwith API login for authenticated flowscontext('Happy Path')/context('Negative Cases')/context('Boundary Cases')itblocks with clear descriptive names- Assertions with
.should()— nevercy.wait(ms) - Custom commands for repeated actions
Key Conventions
✅ For authenticated features, login via API in beforeEach (cy.request) — not via UI
✅ Use data-testid selectors exclusively
✅ Group tests: context('Happy Path') / context('Negative Cases')
✅ Store all credentials and URLs in environment variables
✅ Use .should() assertions — never cy.wait(ms)
✅ Each test is fully independent — no shared state
✅ Clean up test data after tests when needed
References
references/cypress-conventions.md— Full selector, assertion, and structure rulesreferences/page-object-pattern.md— Page Object Model implementation guideexamples/cypress.config.js— Production-ready configurationexamples/transfer.cy.js— Complete spec file exampleexamples/commands.js— Custom commands referencescripts/init-project.sh— CLI scaffold script