Cypress has adopted Mocha's BDD syntax, which fits perfectly with both integration and unit testing. All of the tests you'll be writing sit on the fundamental harness Mocha provides, namely: describe(), context(), it(), before(), beforeEach(), afterEach(), after(), .only() and .skip().
Cypress Interview Questions
Use cy.intercept() instead to Spy and stub network requests and responses. Earlier we use cy.route for network behavior but cy.server() and cy.route() are deprecated in Cypress 6.0.0. In a future release, support for cy.server() and cy.route() will be removed.
Cypress supports Chrome-family browsers (including Electron and Chromium-based Microsoft Edge), and Firefox.
Cypress has two main components:
- Cypress Test Runner: It includes Test Status, URL Preview, Viewport Sizing, Command Log, App Preview
- Cypress Dashboard: The Cypress Dashboard is a service that provides you access to recorded tests.
Cypress is sitting on the browser itself. In the background of Cypress, there lives the Node.js server. The Node server and the Cypress regularly interact, change, and perform actions supporting each other.
Therefore Cypress has access to both the front and back end of the application. Cypress can alter the browser behavior at the run time by handling DOM and modifying the requests and responses of the network on the fly.
Cypress comprises a free, open-source, locally installed Test Runner and a Dashboard Service for recording your tests.
Cypress supports TDD by helping us set up and start writing tests while building our application locally.
Cypress Dashboard Service can record your test and runs after building up a suite of tests and integrating Cypress with your CI Provider.
Here are some features:
- Time Travel
- Debug Tools
- Automatic Waiting
- Network Traffic Control
- Consistent Results
- Cross browser Testing
- Spies, Stubs, and Clocks
- Screenshot and Video Capturing
Cypress Desktop Application: macOS, Linux, Windows
Node JS: Using NPM. Node JS 12 or 14 and above supported
Cypress also support CentOS and Docker.
Shadow DOM allows hidden DOM trees to be attached to elements in the regular DOM tree. Shadow DOM is not a new thing by any means — browsers have used it for a long time to encapsulate the inner structure of an element. Use shadow() function to handle shadow dom: