Cypress folder structure helps organize your test files and support code clearly. It makes testing easier and faster to manage.
Cypress folder structure
cypress/
├── e2e/
│ └── *.cy.js (or .ts) # Your test files
├── fixtures/
│ └── *.json # Sample data files
├── support/
│ ├── commands.js # Custom commands
│ └── e2e.js # Support file loaded before tests
├── plugins/
│ └── index.js # Plugins configuration (Cypress 9 and below)
cypress.config.js # Main Cypress config fileThe e2e folder holds your actual test scripts.
The fixtures folder stores sample data used in tests.
e2e folder.cypress/e2e/login.cy.js
cypress/fixtures/user.json
cypress/support/commands.js
cypress.config.js
This simple test visits example.com and checks if the page title contains 'Example Domain'. It should be placed inside the cypress/e2e folder.
// cypress/e2e/sample.cy.js describe('Sample Test', () => { it('Visits example.com and checks title', () => { cy.visit('https://example.com') cy.title().should('include', 'Example Domain') }) })
Keep your test files inside cypress/e2e for Cypress to find them automatically.
Use the support folder to add reusable commands and setup code.
Fixtures help keep test data separate from test logic, making tests cleaner.
Cypress folder structure organizes tests, data, and support code clearly.
Use e2e for tests, fixtures for data, and support for helpers.
Following this structure makes your tests easier to write, read, and maintain.
Practice
Solution
Step 1: Understand folder purposes
Thee2efolder is designed to hold end-to-end test files in Cypress.Step 2: Differentiate from other folders
fixturesholds test data,supporthas helper code, andpluginsmanages plugins, not tests.Final Answer:
e2e-> Option DQuick Check:
Tests go ine2efolder [OK]
e2e folder by default [OK]- Confusing
fixtureswith test files - Thinking
supportholds tests - Assuming
pluginsstores tests
Solution
Step 1: Recall default Cypress folder structure
Fixture files are stored directly inside thecypress/fixturesfolder.Step 2: Eliminate incorrect paths
Options placing fixtures insidesupportore2eare incorrect. Also,fixtures/cypressis not standard.Final Answer:
cypress/fixtures -> Option AQuick Check:
Fixtures folder iscypress/fixtures[OK]
cypress/fixtures [OK]- Placing fixtures inside
support - Adding extra nested folders incorrectly
- Confusing fixtures with test files location
cypress/
e2e/
fixtures/
support/
commands.js
index.jsSolution
Step 1: Identify default support file
Cypress automatically loadscypress/support/index.jsas the support file.Step 2: Differentiate from other files
commands.jsis imported insideindex.js, but Cypress looks forindex.jsby default.Final Answer:
cypress/support/index.js -> Option BQuick Check:
Support file =cypress/support/index.js[OK]
support/index.js by default [OK]- Choosing commands.js as main support file
- Looking in e2e or fixtures folders for support
- Assuming support file is optional
cypress/support instead of cypress/e2e. What issue will you face?Solution
Step 1: Understand folder roles
Thesupportfolder is for helper code, not test files.Step 2: Consequence of wrong placement
Cypress only runs tests insidee2efolder by default, so tests insupportwon't run.Final Answer:
Tests will not run because Cypress does not look for tests insupport-> Option AQuick Check:
Tests must be ine2e, notsupport[OK]
e2e folder won't run [OK]- Assuming tests run anywhere inside cypress folder
- Confusing support folder as test location
- Thinking fixtures affect test execution location
Solution
Step 1: Identify fixture folder purpose
Thecypress/fixturesfolder is meant for test data files, including environment-specific data.Step 2: Organize environment data properly
Using subfolders likedevandprodinsidefixtureskeeps data organized and easy to load.Final Answer:
Place all environment files insidecypress/fixtureswith subfolders likedev,prod-> Option CQuick Check:
Environment data belongs infixtureswith subfolders [OK]
fixtures for environment data [OK]- Putting data in
supportfolder - Mixing data files with test files in
e2e - Creating folders outside Cypress structure
Ready to prove it?
Pass the test and this pattern moves unknown
