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

0.1.1 • Public • Published

@pepeeja/cypress-graphql

license npm latest package npm type definitions

Install

npm install -D @pepeeja/cypress-graphql

Configuration

Import the package in the file cypress/support/commands.js or cypress/support/commands.ts:

import '@pepeeja/cypress-graphql';

Commands

cy.graphqlContext

Creates isolated GraphQL mock which has private context. Context is exposed as function (gql) => {}

cy.graphqlContext((gql) => {
  gql
    .schemaFromString(schema)
    .options({ url: 'http://localhost:4000/graphql' })
    .mock('GetBooks', {
      books: [
        {
          id: 1,
          title: 'Test title',
          author: 'Test author',
        },
      ],
    });
});

cy.graphqlConfig

Creates global configuration which will be applied to all cy.graphqlMock commands.

cy.graphqlConfig({
  schemaString: schema,
  options: { url: 'http://localhost:4000/graphql', delay: 0, method: 'POST' },
});

cy.graphqlMock

Mocking outgoing graphql query based on operation name.

cy.graphqlMock('GetBooks', {
  books: [
    {
      id: 1,
      title: 'Test title',
      author: 'Test author',
    },
  ],
});

Examples

You can find working application here.

License

This project is licensed under the terms of the MIT License

Package Sidebar

Install

npm i @pepeeja/cypress-graphql

Weekly Downloads

9

Version

0.1.1

License

MIT

Unpacked Size

23.9 kB

Total Files

35

Last publish

Collaborators

  • mrcatlait