Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
cypress/commands/index.js
// --------------------------------------
// 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