0
0
Cypresstesting~5 mins

Cypress folder structure

Choose your learning style9 modes available
Introduction

Cypress folder structure helps organize your test files and support code clearly. It makes testing easier and faster to manage.

When starting a new Cypress test project to keep files neat.
When adding new tests and you want to place them in the right folder.
When sharing your project with teammates so everyone understands where things are.
When debugging tests and you need to find support files or fixtures quickly.
When configuring Cypress to load custom commands or plugins.
Syntax
Cypress
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 file

The e2e folder holds your actual test scripts.

The fixtures folder stores sample data used in tests.

Examples
A test file for login tests placed inside the e2e folder.
Cypress
cypress/e2e/login.cy.js
A JSON file with user data used in tests.
Cypress
cypress/fixtures/user.json
File where you add custom commands to reuse in tests.
Cypress
cypress/support/commands.js
Main configuration file to set base URL, timeouts, and other settings.
Cypress
cypress.config.js
Sample Program

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
// 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')
  })
})
OutputSuccess
Important Notes

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.

Summary

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.