chai-graphql v4.0.0 is a Chai plugin for asserting GraphQL responses, including data matching and error checking. It unwraps response.data and response.errors automatically and supports deep equals, subset matching, and error message validation with strings or regexes. Actively maintained with monthly releases, it works with both parsed JSON and local objects. Differentiated by its Chai integration and simple API for common GraphQL testing patterns.
npm install chai-graphqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to install the plugin and use assert.graphQL, assert.graphQLSubset, expect.graphQl, and graphQLError.
Always use exact casing: graphQL (capital Q, capital L), graphQl (capital Q lowercase L), graphQLError (capital Q, capital L, capital E).
Use Chai v4.x; check plugin compatibility before upgrading.
To check both data and errors, call assert.graphQLError after assert.graphQL for error presence.
Use subset with care: {} matches any data, so use expectedData to narrow assertions.Update engine requirement or test on your Node version; consider migrating to chai-graphql v5 if available.
Use: const chaiGraphQL = require('chai-graphql').default; (CJS) or import chaiGraphQL from 'chai-graphql' (ESM).Add chai.use(chaiGraphQL) in setup file before tests.
Ensure response argument is an object with data and/or errors properties.
No dependency data recorded yet.