Registry / testing / graphql-tester

graphql-tester

JSON →
library0.0.5jsnpmunverified

A test framework for executing integration tests against GraphQL services. Current version 0.0.5 uses Promises and supports HTTP POST with configurable endpoint, method, and content type. It returns structured responses with success, status, headers, data, and errors. Differentiators include promise-based chaining usable with Mocha and optional application server integration. Release cadence is irregular (no recent updates).

npm install graphql-tester
INSTALL
IMPORT
SIG · GRAPHQL-TESTER
G
graphql-tester
testingjavascriptv0.0.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

tester
import { tester } from 'graphql-tester';
const { tester } = require('graphql-tester');
ESM import used in examples; CommonJS require works but may fail in strict ESM environments.
tester
const { tester } = require('graphql-tester');
CommonJS require is valid for Node < 12 or when using --require.
default
import tester from 'graphql-tester';
import { tester } from 'graphql-tester';
Default export is also available as a function; named export is preferred.

Shows creating a tester with optional URL from env, executing a GraphQL query, and accessing response fields.

import { tester } from 'graphql-tester'; const test = tester({ url: process.env.GRAPHQL_URL || 'http://localhost:4000/graphql', }); async function run() { const response = await test('{ hello }'); console.log(response.success, response.data); } run().catch(console.error);
Debug
Known issues
gotchaThe tester function returns a promise that resolves even for HTTP errors (e.g., 400) as long as the GraphQL response contains an 'errors' field.
fix
Check response.success or response.errors to distinguish client errors.
affects: >=0.0.5
gotchaDefault HTTP method is POST, but if you set method: 'GET', the query string is sent as a URL query parameter ?query=... – ensure your server supports GET for GraphQL.
fix
Confirm server supports GET requests with GraphQL.
affects: >=0.0.5
gotchaThe 'server' option starts a child process before tests; it may not work with all application servers and can cause hanging if the server doesn't exit cleanly.
fix
Avoid using the 'server' option unless you manage server lifecycle externally.
affects: >=0.0.5
gotchaContent-Disposition header is not returned in 'headers' – only response.headers from the HTTP library is passed through.
fix
Access raw response via 'raw' property if you need original response details.
affects: >=0.0.5
Errors
Common errors & fixes
tester is not a function
Importing the default export incorrectly or using CommonJS require without destructuring.
fix
Use 'import { tester } from "graphql-tester"' or 'const { tester } = require("graphql-tester")'.
self signed certificate in certificate chain
Using HTTPS with a self-signed certificate; node rejects by default.
fix
Set NODE_TLS_REJECT_UNAUTHORIZED=0 (only for testing) or configure the server with a valid certificate.
connect ECONNREFUSED
No server running at the specified URL.
fix
Ensure your GraphQL server is running on the expected host and port.
Upgrade
Version history
0.0.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
graphql-tester — npm install graphql-tester · libregistry