Folder Structure in a Cypress Project
Folder Structure in a Cypress Project – Explained Simply
When you set up Cypress in a project (npx cypress open or npm install cypress), it creates a default folder structure like this:
π Let’s Break It Down
1. cypress/e2e/ ✅
E2E tests (end-to-end) are written here.
-
Test files usually end with
.cy.jsor.cy.ts -
Each file contains one or more
describe()andit()blocks.
π Example: login.cy.js, signup.cy.ts
2. cypress/fixtures/ π
Use this for test data in JSON format.
π Example:
user.json might contain:
You can load it in your test:
3. cypress/support/ π§©
Used for shared logic, like:
-
commands.js: Add custom commands usingCypress.Commands.add() -
e2e.js: Runs before every test file (good for global setup)
π Example in commands.js:
4. cypress.config.js ⚙️
The main config file where you define:
-
Base URL
-
Timeouts
-
Reporter settings
-
Test patterns
π Example:
5. Other Optional Folders
-
downloads/: Created if your tests trigger file downloads -
videos/,screenshots/: Cypress saves test run recordings and failure screenshots (if enabled)
π§ Summary
| Folder/File | Purpose |
|---|---|
e2e/ | Where your test files live |
fixtures/ | Test data (e.g., users, products) |
support/ | Reusable code, custom commands |
cypress.config.js | Configuration settings |
Comments
Post a Comment