Created
December 3, 2018 12:40
-
-
Save abhilashshettigar/48f5d54e788c776fbfa3090b383a8379 to your computer and use it in GitHub Desktop.
Revisions
-
abhilashshettigar created this gist
Dec 3, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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) } }) })