{"id":19370076,"url":"https://github.com/bustle/chai-graphql","last_synced_at":"2026-06-17T13:01:26.101Z","repository":{"id":44306311,"uuid":"83389402","full_name":"bustle/chai-graphql","owner":"bustle","description":"GraphQL response matcher for Chai assertion library","archived":false,"fork":false,"pushed_at":"2022-02-10T17:15:24.000Z","size":71,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-10-22T10:21:40.108Z","etag":null,"topics":[],"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/bustle.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}},"created_at":"2017-02-28T04:27:44.000Z","updated_at":"2021-02-03T17:53:53.000Z","dependencies_parsed_at":"2022-08-27T23:04:03.089Z","dependency_job_id":null,"html_url":"https://github.com/bustle/chai-graphql","commit_stats":null,"previous_names":["bustlelabs/chai-graphql"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/bustle/chai-graphql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bustle%2Fchai-graphql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bustle%2Fchai-graphql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bustle%2Fchai-graphql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bustle%2Fchai-graphql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bustle","download_url":"https://codeload.github.com/bustle/chai-graphql/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bustle%2Fchai-graphql/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34449282,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-17T02:00:05.408Z","response_time":127,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-10T08:14:09.719Z","updated_at":"2026-06-17T13:01:26.014Z","avatar_url":"https://github.com/bustle.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"chai-graphql [![npm version](https://badge.fury.io/js/chai-graphql.svg)](https://badge.fury.io/js/chai-graphql) [![Build Status](https://travis-ci.org/bustle/chai-graphql.svg?branch=master)](https://travis-ci.org/bustle/chai-graphql) [![devDependency Status](https://david-dm.org/bustle/chai-graphql/dev-status.svg)](https://david-dm.org/bustle/chai-graphql#info=devDependencies)\n===========\n\nGraphQL response matcher for [Chai](http://chaijs.com/) assertion library\n\nWorks with both parsed JSON responses and local object responses.\n\n## Installation\n```\nnpm install --save-dev chai-graphql\n```\n\n## API\n\nMethods will \"unwrap\" the data and/or payload from a response to make testing less repetitive.\n\n- `assert.graphQl(response, [expectedData])` performs a deep equals on the `response.data` or `response.data.payload` and `expectedData` if present. Throws if there are any errors in `response.errors`. Returns `response.data`\n- `assert.graphQLSubset(response, [subsetOfExpectedData])` performs a subset match of `response.data` or `response.data.payload` and expectedData if present. Throws if there are any errors in `response.errors`. Returns `response.data`\n- `assert.graphQLError(response, [errorMatcher])` throws if there are not any `response.errors`, returns the `response.errors`. `errorMatcher` can be a string, regex or an array of strings or regexes. In the string or regex form the error's message property will be [`match()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match) by the `errorMatcher`. In the array form, each `errorMatcher` is tested against each error in order. If there a greater or fewer number of matchers than errors an it will throw.\n\n## Usage\nIn your setup\n```js\nimport chai from 'chai'\nimport chaiGraphQL from 'chai-graphql'\nchai.use(chaiGraphQL)\n```\n\nin your spec.js\n```js\nvar goodResponse = {\n  data: {\n    foo: 'bar'\n  }\n}\n\n// Passes\nassert.graphQL(goodResponse, { foo: 'bar' })\nassert.graphQLSubset(goodResponse, { foo: 'bar' })\nassert.graphQL(goodResponse)\nassert.graphQLSubset(goodResponse)\nassert.graphQLSubset(goodResponse, { })\nassert.notGraphQLError(goodResponse)\nexpect(goodResponse).to.be.graphQl({ foo: 'bar' })\n\n// Fails\nassert.graphQL(goodResponse, { foo: 'FAIL' })\nassert.graphQL(goodResponse, { })\nassert.graphQLError(goodResponse)\nexpect(goodResponse).to.be.graphQLError()\n\nconst badResponse = {\n  errors: [\n    {\n      message: 'Error message',\n      stack: 'Prints if present'\n    },\n    new GraphQLError('GraphQL Error Object'),\n    new Error('Regular Error')\n  ]\n}\n\n// Passes\nassert.graphQLError(badResponse)\nexpect(badResponse).to.be.graphQLError()\n\nassert.graphQLError(badResponse, 'Error message')\nassert.graphQLError(badResponse, /GraphQL Error Object/)\nassert.graphQLError(badResponse, [\n  'Error message',\n  /GraphQL Error Object/\n])\n\n// fails\nassert.graphQL(badResponse, { foo: 'bar' })\nassert.graphQL(badResponse)\nassert.notGraphQLError(badResponse)\nexpect(badResponse).to.be.graphQl({ foo: 'bar' })\nassert.graphQLError(badResponse, 'Rando Error')\nassert.graphQLError(badResponse, [ 'Error message' ])\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbustle%2Fchai-graphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbustle%2Fchai-graphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbustle%2Fchai-graphql/lists"}