testcafe-graphql-mock
simple testcafe commands for executing a mocked GraphQL server using only the client.
Installation
npm i -D testcafe-graphql-mock
API available
mockGraphQLoptions: MockGraphQLOptions, req, res;
Basic Usage
; // define the schemaconst schema = `type Person { firstname: String! surname: String!} type Query { people: [Person]}`; // define the mockconst mock = firstname: 'Lee' surname: 'Byron' ; // create traditional testcafe request mockconst requestMock = ; // now call the testcafe request mock in fixures as request hooks ; ;
Read schema from .graphql file
You need to use graphQLSchemaFromFile
method from the library.
; // use the graphql schema reader method in your request mocksconst requestMock = ;
Delay the GraphQL mocked response
use the delay
(in milliseconds) parameter in mockGraphQL({})
options
const requestMock = ;
License
MIT
Tell me your issues
you can raise any issue here
Contribution
Any pull request is welcome.
If this plugin helps you in your automation journey, choose to Sponsor
If it works for you , give a Star! ⭐️
- Copyright © 2020- Abhinaba Ghosh