1.2.7 • Published 4 years ago

cy-mock-graphql v1.2.7

Weekly downloads
85
License
MIT
Repository
github
Last release
4 years ago

Cypress Mock GraphQL

Installation

npm install cy-mock-graphql
yarn add cy-mock-graphql

Usage

schema.gql

type Person {
  firstname: String!
  surname: String!
}

type Query {
  people: [Person]
}

myCypressTest.spec.js

import mockGraphQL from 'cy-mock-graphql'
import schema from 'schema.gql'

describe('My Cypress Test', () => {
  beforeEach(() => {
    cy.mockGraphQL(schema, {
      Query: () => ({
        people: () => ([
          {
            firstname: 'Gary',
            surname: 'Ryan'
          }
        ])
      })
    })
  })

  it('Should mock graphql', () => {
    ...
  })
})

API

mockGraphQL(schema, mock, options)

Schema

Mock

  • Optional
  • Type: Object with resolver functions, see example in usage section.

Options

  {
    endpoint: String | default '/graphql'
  }
  • endpoint: specifiy the graphql endpoint

Contributing

git clone ...

yarn
yarn ci

License

MIT

1.2.7

4 years ago

1.2.6

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago