{"id":15433938,"url":"https://github.com/abhinaba-ghosh/graphql-mock-e2e-example","last_synced_at":"2025-03-28T06:12:22.235Z","repository":{"id":103997104,"uuid":"283540528","full_name":"abhinaba-ghosh/graphql-mock-e2e-example","owner":"abhinaba-ghosh","description":"GraphQL queries mocking example with Cypress and Testcafe","archived":false,"fork":false,"pushed_at":"2020-07-29T16:22:47.000Z","size":359,"stargazers_count":0,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-18T08:34:40.586Z","etag":null,"topics":["cypress","graphql","mock","testcafe"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abhinaba-ghosh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-29T15:50:04.000Z","updated_at":"2020-07-29T16:22:49.000Z","dependencies_parsed_at":"2023-07-10T15:32:33.622Z","dependency_job_id":null,"html_url":"https://github.com/abhinaba-ghosh/graphql-mock-e2e-example","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"02e56d664d9dcfc351155e8218befd8fd8e4868e"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhinaba-ghosh%2Fgraphql-mock-e2e-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhinaba-ghosh%2Fgraphql-mock-e2e-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhinaba-ghosh%2Fgraphql-mock-e2e-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhinaba-ghosh%2Fgraphql-mock-e2e-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abhinaba-ghosh","download_url":"https://codeload.github.com/abhinaba-ghosh/graphql-mock-e2e-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245978277,"owners_count":20703678,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cypress","graphql","mock","testcafe"],"created_at":"2024-10-01T18:36:12.177Z","updated_at":"2025-03-28T06:12:22.206Z","avatar_url":"https://github.com/abhinaba-ghosh.png","language":"JavaScript","readme":"# GraphQL-Mock-Example: Testcafe vs Cypress\n\n| Library Used          | NPM Link                                                    |\n| --------------------- | ----------------------------------------------------------- |\n| cypress-graphql-mock  | [here](https://www.npmjs.com/package/testcafe-graphql-mock) |\n| testcafe-graphql-mock | [here](https://www.npmjs.com/package/cypress-graphql-mock)  |\n\n## Instructions to test:\n\n- start the client app\n\n```ssh\ncd client\n\nnpm install\n\nSKIP_PREFLIGHT_CHECK=true npm start\n```\n\n- Testcafe mock tests\n\n```ssh\n# start another terminal in root directory\n\nnpm run testcafe:test\n```\n\n- Cypress mock tests\n\n```ssh\nnpm run cypress:test\n```\n\n## cypress-graphql-mock\n\n### Basic usage\n\n```js\nbeforeEach(() =\u003e {\n  cy.task('getSchema').then((schema) =\u003e {\n    cy.mockGraphql({});\n  });\n});\n\nit('Should mock getUser', () =\u003e {\n  cy.mockGraphqlOps({\n    operations: {\n      getUser: {\n        user: {\n          id: 1,\n          name: 'Name',\n          email: 'Email',\n        },\n      },\n    },\n  });\n\n  cy.visit('/');\n  cy.get('#GET_USER').click();\n  cy.get('#data').should(\n    'contain',\n    JSON.stringify({\n      user: { id: 1, name: 'Name', email: 'Email', __typename: 'User' },\n    })\n  );\n});\n```\n\n## testcafe-graphql-mock\n\n### Basic Usage\n\n```js\nimport { mockGraphQL } from 'testcafe-graphql-mock';\n\n// create traditional testcafe request mock\nconst requestMock = RequestMock()\n  .onRequestTo({ url: 'http://localhost:3000/graphql', method: 'POST' })\n  .respond(async (req, res) =\u003e {\n    await mockGraphQL(\n      {\n        schema,\n        mock,\n      },\n      req,\n      res\n    );\n  });\n\n// now call the testcafe request mock in fixures as request hooks\nfixture(`GraphQL Mock test`)\n  .page('http://localhost:3000/')\n  .requestHooks(requestMock);\n\ntest('test graphql mock data', async (t) =\u003e {\n  await t.click(Selector('button'));\n  await expect(Selector('div')).contains('Lee Byron');\n});\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhinaba-ghosh%2Fgraphql-mock-e2e-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabhinaba-ghosh%2Fgraphql-mock-e2e-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhinaba-ghosh%2Fgraphql-mock-e2e-example/lists"}