Spec files are where your tests actually live. This lesson covers naming conventions, how Cypress discovers spec files, and practical patterns for organizing a growing test suite.
What Is a Spec File?
A spec file is a JavaScript or TypeScript file containing one or more tests, typically organized with describe() and it(). By default, Cypress looks for files matching **/*.cy.{js,jsx,ts,tsx} inside the cypress/e2e folder.
Nothing prevents you from nesting spec files in subfolders that mirror your application's feature areas, Cypress will discover them recursively based on the configured specPattern.
specPattern accepts a glob (or array of globs) controlling which files Cypress treats as specs.
Changing specPattern is useful when migrating an existing test suite into a Cypress-friendly layout.
Component test specs typically use a separate pattern, often colocated next to source files as *.cy.jsx.
Spec File Conventions
Default naming and location conventions Cypress expects out of the box.
Item
Default
E2E spec location
cypress/e2e/
E2E spec extension
.cy.js / .cy.ts / .cy.jsx / .cy.tsx
Component spec pattern
Colocated *.cy.jsx next to components (configurable)
Support file
cypress/support/e2e.js
Fixtures folder
cypress/fixtures/
One Spec File per Feature, Not per Page
A common organizational mistake is creating one spec file per page component. A more durable pattern is organizing by user-facing feature or flow, since a single feature (like checkout) might span several pages, and a single page might support several distinct features.
Group tests around a complete user flow (e.g., "checkout"), not a single component.
Keep each spec file focused enough that a failure's cause is quick to narrow down.
Split an oversized spec file once it starts mixing unrelated concerns.
Running a Subset of Spec Files
You rarely want to run every spec file while actively developing a single feature. The --spec CLI flag and the Test Runner's spec list both let you target a subset quickly.
npx cypress run --spec "cypress/e2e/checkout/**/*.cy.js"
This runs only the spec files inside the checkout folder, useful for fast local iteration.
Common Mistakes
Creating a one-to-one mapping between page components and spec files instead of organizing by user flow.
Letting a single spec file grow to hundreds of lines covering unrelated scenarios.
Forgetting that changing specPattern can silently exclude existing spec files from being discovered.
Not using --spec during local development, leading to slow, unnecessary full-suite runs.
Key Takeaways
Spec files are discovered based on the specPattern configuration, defaulting to cypress/e2e/**/*.cy.{js,ts}.
Organize spec files around user-facing features and flows, not one-to-one with page components.
Nested folders under cypress/e2e/ help keep a large suite navigable.
Use --spec to target a subset of files during local development for faster feedback.
Pro Tip
When a spec file starts needing more than three or four levels of nested describe() blocks to stay organized, that is usually a sign it should be split into multiple, more focused spec files instead.
You now understand how spec files are organized and discovered. Next, learn the roles of describe and it blocks in Describe and It.