Thursday, 10 October 2019

cypress

1. login programatically without using UI

    cy.request('POST', '/login', {
      username,
      password
    })


2. compared to selenium, cypress is consistent 'cause it's running inside browser

3. assertion
  • should/and

4. auto complete
  • /// <reference types="Cypress" />

5. fixture (it's like property file)

6. cypress has its own locator inspector after navigating to webpage

7. stub
cy.intercept('GET', '/api/users', { fixture: 'users.json' }).as('getUsers');
cy.visit('/users');
cy.wait('@getUsers');       //stub /api/users and wait for it, real api is not called


8. wait
  • cy.visit('/users');                                                                //only wait for page load
  • can add below code to wait for an api call to finish
cy.intercept('GET', '/api/another-resource').as('getAnotherResource');
cy.wait('@getAnotherResource');