Cypress.io notes
End-to-end test tool which allows writing test for web apps from a user point of view. Open source and free.
Install and Start:
npm install --save-dev cypress
npx cypress open
Sample of test:

Selecting elements:
The best practice for selecting elements on a page is to use data attribute: data-cy=”unique-value” and then cy.get('data-cy="unique_value"')
For readability use aliases:cy.get('data-cy="unique_value"').as('some_element')
then use cy.get('@some_element')
Select as jQuery element:

Use hook
beforeEach(() => {})
to remove repeated code.
Deal with flaky tests:

Environment variables:
Create: export CYPRESS_MY_ENV_VAR="hello" or npx open --env MY_ENV_VAR="hello"

Use: Cypress.env('MY_ENV_VAR')
Stubs and spies:
Cypress uses the sinon.js library to create test doubles.



Links: