Giter Club home page Giter Club logo

cypress-graphql's Introduction

@shopify/cypress-graphql

Build Status License: MIT npm version npm bundle size (minified + gzip)

Cypress commands for intercepting and testing graphql endpoints.

Installation

Install this package w/ npm or yarn

npm install --dev @shopify/cypress-graphql
yarn add --dev @shopify/cypress-graphql

Then in your cypress/support/index files, import the entire package to register these commands.

import '@shopify/cypress-graphql';

Typescript types are automatically included, so no further action is required.

Usage

cy.interceptGql

This command sets up spies and stubs for a graphql endpoint, similar to cypress route intercepts. This registers a top-level route alias called GraphQL. Optionally, but definitely encouraged is providing an array of known operations, which will then be registered as sub-operations with their own aliases.

Intercept any request

cy.interceptGql('**/graphql')                         // register route intercepts
cy.get('button[type="submit"]').click()               // make the UI send a request
cy.wait('@GraphQL').its('status').should('eq', 200)   // test the response

Intercept a specific operation

cy.interceptGql('**/graphql', ['UserQuery'])          // register route intercepts
cy.get('button[type="submit"]').click()               // make the UI send a request
cy.wait('@UserQuery').its('status').should('eq', 200) // test the response

Stub a specific operation

cy.interceptGql('**/graphql', [
  ['UserQuery', { statusCode: 400, body: { data: null, errors: ['fake err']  } }]
])                                                    // provide a fake error
cy.get('button[type="submit"]').click()               // make the UI send a request
cy.wait('@UserQuery').its('status').should('eq', 400) // test the response

cypress-graphql's People

Contributors

rckeller avatar dependabot[bot] avatar

Stargazers

Atul Sharma avatar  avatar Devin Norgarb avatar Neil John S. Capule avatar Anas Fitiani avatar David Lakin avatar Eron Moraes avatar Sadaf Najam avatar Felipe Lima avatar  avatar Mike Shi avatar Dan Dimerman avatar Mohit Yadav avatar

Watchers

Shay avatar Lourens Naudé avatar Elvio Vicosa avatar Jeff Bruton avatar Mai avatar Lucas Souza avatar Ryan Florence avatar Stella Miranda avatar Ben Doyle avatar Stephen Hunter avatar Luiz Adolpho avatar Bart Piotrowski avatar Shadab Rashid avatar Jeremy Morony avatar Dan Menard avatar Mark Ryan avatar Michael Nugent avatar Sebastian Skopp avatar Julia Winn avatar James Cloos avatar Misha Korablin avatar Thomas Conner avatar Stephen Hukish avatar Ryan Self avatar Karthik K N avatar Corwin Brown avatar Arpan Podduturi avatar João Júnior avatar Daniel Leroux avatar Alex Fi avatar Ahmad Alhour avatar Nik Ivanov avatar Tim Lombardo avatar Kaj Drobin avatar Paul Gagliardi avatar Annett Forcier avatar Satish Kanwar avatar Liz McDonald avatar Alejandro Gonzalez avatar Topher Bullock avatar Anita Mehrotra avatar  avatar Dave McVittie avatar Robleh Jama avatar Nick Lee avatar Damyan Petkov avatar Julia Nguyen avatar Armando avatar Nicholas Simmons avatar Kirsten Westeinde avatar Pauline Ramos avatar  avatar  avatar  avatar ryan avatar Ian Martin avatar Will Mowat avatar John Benson avatar Arbab Ahmed avatar Nick Bell avatar Derek Braid  avatar  avatar  avatar Anya Li avatar Tony Gaetani avatar Shashwat Singh avatar Sebastián Osorio avatar Bill Fienberg avatar Elijah McPherson avatar Katarina Batina avatar Ted Armstrong avatar Fatima Sajadi avatar Ian Donahue avatar Emily avatar Jeremy Ward avatar Alëna Iouguina avatar Yiğit Özkavcı avatar Christian Mackie avatar Fran avatar Robin Dykema avatar Scott Moorhouse avatar Preethi Krishnamoorthy Ramesh Kumar avatar  avatar Tidjane Tall avatar nicklepine avatar Joseph Kim avatar  avatar Keyvan K. avatar Robert Byrne avatar  avatar Fred Dawson avatar  avatar  avatar MesamH avatar  avatar Victor Daniel Catamo Rojas avatar Stephen Smyth avatar Charles avatar Matt Vaile  avatar  avatar

cypress-graphql's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.