Structuring E2E tests
Cypress tests are structured using the describe()
, context()
, it()
, and specify()
functions, which are borrowed from Mocha (Mocha is a feature-rich JavaScript testing framework that runs on Node.js and in the browser, designed to make asynchronous testing simple and enjoyable. It is highly regarded for its versatility in testing applications across both the front- and backends, offering a wide range of benefits to developers). The describe()
function is used to group related tests, context()
is similar to describe()
, and it()
and specify()
are used to write individual test cases.
We’re going to structure our tests around the functionality of our calculator application. Our calculator performs four operations: addition, subtraction, multiplication, and division. In our e2e
folder in the cypress
folder, we’ll create a file called calculator.cy.ts
:
Figure 8.1 – The calculator.cy.ts file in e2e in the cypress folder...