Skip to content

Instantly share code, notes, and snippets.

@abhilashshettigar
Created December 3, 2018 12:40
Show Gist options
  • Select an option

  • Save abhilashshettigar/48f5d54e788c776fbfa3090b383a8379 to your computer and use it in GitHub Desktop.

Select an option

Save abhilashshettigar/48f5d54e788c776fbfa3090b383a8379 to your computer and use it in GitHub Desktop.

Revisions

  1. abhilashshettigar created this gist Dec 3, 2018.
    16 changes: 16 additions & 0 deletions command.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    Cypress.Commands.add("Login", () => { //Making A custom command for loggin in to the application
    cy.request({
    method: 'POST',
    url: '/users/authenticate', // Base URL will be prepended which is decalred in cypress.json
    body: { //Passing Email and Password for log in
    "email": "{email}",
    "password": "{pass}"
    }
    }).then(($body) => { //Assertion for Response status should be 200
    if (expect($body.status).to.eq(200)) {
    localStorage.setItem('currentUser', JSON.stringify($body.body)) //Saving Auth token for further user Interactions
    } else {
    console.log('Login Failed', $body)
    }
    })
    })