Cypress · Browser testing end to end

How do you set up a Cypress project?

EasysetupconfigurationtypescriptUpdated Oct 2026
Quiz this track

Short answer

Install Cypress, run it once to scaffold the folders, and configure baseUrl, spec patterns and the support file in cypress.config.ts. Add a TypeScript config and the Cypress types for editor support.

A new project needs the Cypress package, a config file and the conventional folder layout. Running the interactive runner once creates example specs and support files. After that you can delete the examples and write your own suite.

bash
npm install --save-dev cypress
npx cypress open
The first open scaffolds cypress/e2e, cypress/support and cypress.config.ts.
ts
import { defineConfig } from "cypress";

export default defineConfig({
  e2e: {
    baseUrl: "http://localhost:3000",
    supportFile: "cypress/support/e2e.ts",
    specPattern: "cypress/e2e/**/*.cy.ts",
    viewportWidth: 1280,
    viewportHeight: 800,
  },
});
baseUrl makes a relative cy.visit work, and specPattern controls which files run.

The typical layout

  • cypress/e2e for end-to-end specs
  • cypress/support for shared commands and global hooks
  • cypress/fixtures for JSON or other test data
  • cypress.config.ts for project configuration
  • A root tsconfig.json that includes the Cypress types

Add the Cypress types to the TypeScript configuration so cy, Cypress and the custom command declarations resolve in the editor. If the project already has a frontend tsconfig, keep the Cypress config separate to avoid mixing browser and Node settings.

Commit cypress.config.ts and the support files. Do not commit screenshots, videos or downloaded binaries; add them to the ignore file.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1What does baseUrl change in a test?
  2. 2Why keep a separate tsconfig for Cypress?
  3. 3Which folders should be committed?
  4. 4How do you change the default spec location?

Say it in the interview

I install Cypress and run it once so it scaffolds the config, support and example folders. Then I set baseUrl, specPattern and the support file in cypress.config.ts, and make sure the Cypress types are available to TypeScript. I keep e2e specs, fixtures and support code in the cypress folder and ignore screenshots and videos. The goal is a small, predictable config that a new teammate can run immediately.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Cypress mock interview and get scored feedback on depth, clarity and confidence.