Created
October 29, 2018 12:16
-
-
Save Samueldhardy/dabfe940016f737dc2527fd35dc62ccb to your computer and use it in GitHub Desktop.
cypress/commands/index.js
This file contains 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 characters
// -------------------------------------- | |
// Log in and return auth token. | |
// -------------------------------------- | |
Cypress.Commands.add('login', () => { | |
const apiLoginRoot = Cypress.env('API_LOGIN_ROOT'); | |
const body = { | |
email, | |
password, | |
}; | |
return cy.request({ | |
method: 'POST', | |
url: `${apiLoginRoot}/oauth/token`, | |
body, | |
}); | |
}); | |
// -------------------------------------- | |
// Post to GQL Server return response data object | |
// -------------------------------------- | |
Cypress.Commands.add('postGQL', (authToken, query) => { | |
const gqlServerRoot = Cypress.env('GQL_SERVER_ROOT'); | |
return cy.request({ | |
method: 'POST', | |
url: `${gqlServerRoot}/graphql`, | |
headers: { | |
Authorization: `Bearer ${authToken}`, | |
}, | |
body: { query }, | |
failOnStatusCode: false, | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment