npm.io
0.0.3 • Published 4 years ago

@mgansler/cypress-graphql

Licence
MIT
Version
0.0.3
Deps
0
Size
2 kB
Vulns
0
Weekly
0

Cypress GraphQL

This library aims to simplify interception GraphQL calls with Cypress.

Examples

A simple fetch:

cy.graphql('fixture.json').as('fetch')

// make the call
cy.findByRole('button', { name: 'Fetch it!' }).click()

cy.wait('@fetch')

Filter for some text in the GraphlQL query:

cy.graphql('user-info.json', { filter: 'User' }).as('fetch-user')
cy.graphql('something.json', { filter: 'Something' }).as('fetch-something')

// make the calls
cy.findByRole('button', { name: 'Load user info!' }).click()
cy.wait('@fetch-user')

cy.findByRole('button', { name: 'Load something' }).click()
cy.wait('@fetch-something')

Intercept mutations:

cy.graphql('mutation-response.json', { operationType: 'mutation' }).as('mutation')

// make the call
cy.findByRole('button', { name: 'Update data' }).click()

cy.wait('@mutation')

Keywords