Updated recently
Last updated:
Quick Answer: The most common Cypress interview questions cover: Cypress architecture (browser proxy vs WebDriver), selectors (cy.get vs cy.contains), API interception (cy.intercept), Page Object Model, CI/CD integration, and handling flaky tests.
What is Cypress?
Cypress is a JavaScript-only end-to-end testing framework that runs inside the browser proxy. It provides time-travel debugging, automatic waiting, real-time reloads, and built-in network interception.
Basic Cypress Interview Questions
1. What is Cypress and how does it differ from Selenium?
Cypress runs inside the browser via a proxy architecture, giving it direct access to the DOM and network. Selenium operates outside the browser via WebDriver protocol. Cypress is JavaScript-only; Selenium supports multiple languages.
2. What languages does Cypress support?
Cypress supports JavaScript and TypeScript only. It does not support Python, Java, or C#.
3. What is the difference between cy.get and cy.contains?
cy.get selects elements by CSS selector. cy.contains finds elements containing specific text. Use cy.get for precise CSS targeting; use cy.contains for text-based selection.
4. How does Cypress handle alerts and popups?
Cypress automatically handles window.alert, window.confirm, and window.prompt. Use cy.on(‘window:alert’) to stub or assert alert text.
5. What is the difference between cy.visit and cy.request?
cy.visit opens a URL in the browser and renders the page. cy.request makes an HTTP request without rendering, useful for API testing or setting up test state.
Intermediate Cypress Interview Questions
6. What is the Page Object Model in Cypress?
POM extracts page-specific selectors and actions into reusable classes. Instead of writing cy.get(‘#login-btn’) in every test, create a loginPage.clickLogin() method.
7. How do you intercept API requests in Cypress?
Use cy.intercept(‘GET’, ‘/api/users’, { fixture: ‘users.json’ }) to stub responses. This lets you test frontend behavior without a real backend.
8. What are Cypress custom commands?
Custom commands are reusable functions added to the Cypress namespace. Define them in cypress/support/commands.js and call them like built-in commands.
9. How do you handle file uploads in Cypress?
Use cy.get(‘input[type=”file”]’).selectFile(‘file.txt’) (Cypress 9+) or the cypress-file-upload plugin for older versions.
10. What is the difference between cy.wait and auto-waiting?
Cypress auto-waits for elements to exist, be visible, and be actionable. cy.wait(5000) adds an explicit pause, which is generally discouraged.
Advanced Cypress Interview Questions
11. How do you test cross-origin navigation in Cypress?
Cypress cannot control cross-origin navigation due to its browser proxy architecture. Use cy.origin() (Cypress 12+), test the API directly, or switch to Playwright.
12. How do you run Cypress tests in parallel?
Use Cypress Cloud (paid) for built-in parallelization, or split test files across CI machines using –spec flags.
13. How do you handle authentication in Cypress tests?
Options: cy.session() to cache login, API login via cy.request() to set cookies directly, or stub authentication endpoints with cy.intercept().
14. What is the difference between cy.fixture and cy.intercept?
cy.fixture loads static JSON data files. cy.intercept stubs network responses. Combine them: cy.intercept(‘/api/data’, { fixture: ‘data.json’ }).
15. How do you debug Cypress tests?
Use Cypress Test Runner (interactive mode), cy.debug() to pause execution, cy.log() for console output, and time-travel debugging.
More Questions to Practice
- How do you implement data-driven testing in Cypress?
- What is the difference between before and beforeEach?
- How do you handle multiple browser tabs in Cypress?
- How do you test mobile responsiveness in Cypress?
- What are the limitations of Cypress?
- How do you integrate Cypress with Jira?
- How do you test WebSocket connections in Cypress?
- What is the difference between Cypress and Playwright?
- How do you handle iFrames in Cypress?
- How do you test file downloads in Cypress?
- How do you mock geolocation in Cypress?
- What is the Cypress Dashboard?
- How do you test GraphQL APIs in Cypress?
- How do you handle cookie-based authentication?
- What is the difference between cy.stub and cy.intercept?
- How do you test drag-and-drop in Cypress?
- How do you handle dynamic content in Cypress?
- What is the Cypress testing library?
- How do you optimize Cypress test execution speed?
- How do you test Shadow DOM elements in Cypress?
- How do you implement BDD with Cypress and Cucumber?
- How do you test progressive web apps with Cypress?
- How do you handle SSL certificates in Cypress?
- What are Cypress plugins?
- How do you test file uploads with drag-and-drop?
Training Resources
Build hands-on Cypress skills with SkilBrill Cypress Training.
FAQ
How do I prepare for a Cypress interview?
Focus on: architecture differences from Selenium, cy.intercept for API mocking, Page Object Model, CI/CD integration, and debugging techniques.
