QA Interview Hub · Knowledge base · Quizzes · Українська

Cypress › Outdated-answer traps

How do you recognise an outdated answer about Cypress structure?

An outdated answer uses names Cypress removed: cypress.json, cy.server and cy.route, and since version 16 Cypress.env() and cy.exec(). The current counterparts are the cypress.config file with specPattern, cy.intercept(), cy.env() or Cypress.expose() and cy.task(), and video has been off by default since version 13. Exact versions are checked against the Migration Guide.

Cypress · Currency

A candidate says "cypress.json and cy.route". What in that answer is outdated?

Cypress has changed noticeably: version 10 redesigned the config and structure, 12 removed old network and cookie APIs, 13 turned video off by default, 16 removed Cypress.env() and cy.exec(). The interviewer does not listen for a version number but for whether your answer matches current Cypress. The table below is a quick check.

How it works

Each row is a pair "what it was, what it became". Remember not just the new word but the reason: cy.intercept gives one API for any requests instead of two separate commands, cy.session caches state instead of moving cookies by hand, and setupNodeEvents keeps Node logic in the config itself.

OutdatedCurrent
cypress.jsoncypress.config.js / .ts
cypress/integrationcypress/e2e, *.cy.ts files
testFilesspecPattern
cypress/plugins/index.jssetupNodeEvents in the config
cy.server(), cy.route()cy.intercept() (old commands removed in v12)
Cypress.Cookies.preserveOncecy.session() (removed in v12)
Video is always recordedOff by default since v13
Cypress.env()Since v16: cy.env() for secrets, Cypress.expose() for the rest
cy.exec()Removed in v16: cy.task() with child_process

Example: from an old answer to a modern one

// Outdated: cy.server() and cy.route()
cy.server();
cy.route('GET', '/api/users', 'fixture:users.json');

// Current
cy.intercept('GET', '/api/users', { fixture: 'users.json' });
// cypress.config.ts (instead of cypress.json and plugins/index.js)
import { defineConfig } from 'cypress';

export default defineConfig({
  e2e: {
    specPattern: 'cypress/e2e/**/*.cy.ts',
    setupNodeEvents(on, config) {
      // Node events and plugins go here
      return config;
    },
  },
});

Limits and alternatives

The table reflects the state in November 2026 and will age on its own. More reliable than memory: the Migration Guide page on docs.cypress.io and the changelog, where each removal is listed with its version. On a legacy project reality can differ: cypress.json or old versions may live there, and that is no reason to call an answer wrong but a reason to name the migration path.

What a migration looks like in practice

Old versions are usually migrated step by step, not in one jump: first to 10 (the new config and structure), then through the changes of 12 (cy.server, cy.route, preserveOnce removed), then to the current one. At every step read the Migration Guide section for that version: it lists what was removed and what replaces it. A useful habit: run the whole suite after each step and record the result, because a removed command breaks a test at once, while a changed behaviour (for example test isolation) shows up selectively.

// Before (pre-16): environment variables and a shell from a test
const apiUrl = Cypress.env('API_URL');
cy.exec('node scripts/seed.js');

// After: public via expose, a secret via cy.env, a shell via task
const apiUrl = Cypress.expose('API_URL');
cy.env(['API_TOKEN']).then(({ API_TOKEN }) => {
  cy.request({ url: '/api/me', auth: { bearer: API_TOKEN } });
});
cy.task('seed'); // in setupNodeEvents: child_process.execFile(...)

Variables are declared in the env block (secrets, read asynchronously through cy.env()) and the expose block (public, read synchronously through Cypress.expose()) of the config; an undefined variable yields undefined. All of this follows a general trend: Cypress separates secrets from public settings and moves running shell commands from the page into Node.

Common mistakes

  • Learning only the words from the table without the reasons: no answer to "and why?".
  • Taking solutions from old articles: cy.route, preserveOnce or cy.exec will not work in fresh code.
  • Mixing up the binary and package versions during a migration: check with cypress verify.

Check yourself

Old code has cy.server() and cy.route(). What replaces them and since which version are they unavailable?

Answer

cy.intercept(); the old commands were removed in Cypress 12.

A script runs a shell command through cy.exec(). What changes in v16?

Answer

cy.exec() is removed; move the command into cy.task() and run it in Node through child_process.

In the interview. Junior: The config is cypress.config, tests live in e2e, specPattern replaces testFiles, plugins sit in setupNodeEvents. The network is intercepted with intercept, sessions are kept with cy.session. Middle/Senior: I also know the newer changes: video is off since 13, and in 16 Cypress.env() (there are cy.env() and Cypress.expose()) and cy.exec() were removed. For accuracy I check the Migration Guide.

More articles in this chapter