@mgansler/cypress-graphql
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

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')

Readme

Keywords

Package Sidebar

Install

npm i @mgansler/cypress-graphql

Weekly Downloads

0

Version

0.0.3

License

MIT

Unpacked Size

1.57 kB

Total Files

2

Last publish

Collaborators

  • mgansler