What do the project structure and the Cypress config look like?
Since version 10 the Cypress config lives in code, in cypress.config.js or .ts, and cypress.json is no longer used. It has separate blocks for e2e and component, plus baseUrl, specPattern, defaultCommandTimeout, retries and setupNodeEvents, which runs in Node. Tests live in cypress/e2e, data in cypress/fixtures, shared code in cypress/support. A mistake in specPattern produces the symptom «no specs found».
Cypress · Architecture
The project holds a cypress.json that the docs you read never mention. Why?
A newcomer clones an old tutorial project, sees cypress.json and integration instead of e2e, and the new Cypress version finds no tests at all. The structure changed: since version 10 the config moved into code. This lesson explains what lives where now, what the main settings mean and how to tell a modern answer from an outdated one.
How it works and why. Since version 10 the config lives in a cypress.config.js or .ts file, and the old cypress.json is no longer used. The config is code that Node executes before the run, so imports, conditions and reading environment variables work there. It has separate blocks for e2e and component: different test types have different specs, dependencies and settings. The rest of the project is simple: cypress/e2e for tests, cypress/fixtures for data, cypress/support for shared code loaded before every spec.
What lives where in the project
The support/e2e.ts file runs before every spec, so custom commands and global hooks are registered there. In the config, setupNodeEvents runs in Node, not in the browser: this is where cy.task and event subscriptions are described. The baseUrl setting makes cy.visit('/') short and lets you change the environment in one place.
Example: from cypress.json to a modern config. The old file had flat keys and an integration folder. The modern equivalent:
// cypress.config.ts
import { defineConfig } from 'cypress';
export default defineConfig({
e2e: {
baseUrl: 'https://staging.example.com',
specPattern: 'cypress/e2e/**/*.cy.ts',
defaultCommandTimeout: 6000,
retries: { runMode: 2, openMode: 0 },
setupNodeEvents(on, config) {
// cy.task, plugins, reports: this is Node
return config;
},
},
});
Now each line is visible. baseUrl lets you write cy.visit('/login'). specPattern says which files count as tests: if it is wrong, Cypress "does not see" specs. defaultCommandTimeout sets how long a lookup command is retried. retries configures rerunning failed tests separately for run and open. Shared logic lives in support, and the test just calls it:
// cypress/support/commands.ts
Cypress.Commands.add('login', (email: string, password: string) => {
cy.request('POST', '/api/login', { email, password });
});
// cypress/e2e/profile.cy.ts
it('opens the profile', () => {
cy.login('qa@example.com', 'secret'); // baseUrl from the config
cy.visit('/profile');
});
This structure keeps a test short and readable: login, data and settings are moved out, and the test itself describes behaviour.
The config is playwright.config.ts. Instead of separate e2e and component blocks there are projects: different browsers, devices, a setup project for login. There is no support folder: shared logic lives in fixtures through test.extend.
Limits and alternatives. A config in code is flexible but easy to make tangled: sensitive values should not be hard-coded, pass them from environment variables (with the CYPRESS_ prefix or through --env) or CI. Settings that depend on the environment are better returned from the config by a function than by copying files. The folder layout can be changed through specPattern and supportFile, but the default layout eases onboarding, so deviate with a reason.
Common mistakes.
- Looking for or creating
cypress.jsonin a modern project: in 10+ it is ignored. - A wrong
specPattern: the tests sit in a folder the pattern does not cover and Cypress says there are no specs. - Putting secrets and passwords in a config that lands in the repository.
- Mixing Node logic (reading files) into test code instead of
setupNodeEventsandcy.task. - Raising
defaultCommandTimeoutinstead of fixing the wait: it masks the real cause.
Check yourself
After an upgrade Cypress says it found no specs although *.cy.ts files exist. Where do you look for the cause?
Answer
In the config: specPattern should cover the folder with the tests (by default cypress/e2e/**/*.cy.{js,jsx,ts,tsx}), and the old cypress.json is ignored in version 10+. I check that the settings are in cypress.config.ts in the e2e block and that the pattern matches the real location of the files.
Where does code in the config run: in the browser or in Node, and what follows for cy.task?
Answer
Everything in cypress.config.ts, setupNodeEvents included, runs in Node. That is why the tasks for cy.task are described there: they can reach files and a database, and the test in the browser calls them by name.