← ClaudeAtlas

graphql-yoga-testslisted

Use whenever a GraphQL Yoga or Mercurius server needs tests: in-process yoga.fetch() for queries and mutations, executor-http for subscriptions and streaming, auth headers, and checks for disabled introspection and persisted operations. Mercurius app.inject() patterns are in its references.
testland/qa-skills · ★ 0 · Testing & QA · score 72
Install: claude install-skill testland/qa-skills
# graphql-yoga-tests ## Overview Per [the-guild.dev/graphql/yoga-server/docs/features/testing](https://the-guild.dev/graphql/yoga-server/docs/features/testing): "Calling the `yoga.fetch` method does not send an actual HTTP request. It simulates the HTTP request which 100% conforms with how Request/Response work." Structurally different from Apollo's `executeOperation` - Yoga's testing path goes through the HTTP transport layer including middleware, headers, and response codes. There is no separate "in-process" vs "HTTP-layer" choice. ## When to use - Unit / integration tests for a Yoga-based GraphQL server. - Subscription tests (SSE / WS via Yoga). - Production-config gates for Yoga's plugin-based controls. ## Authoring ### Install ```bash npm install --save-dev graphql-yoga @graphql-tools/executor-http ``` ### Basic test Per Yoga docs: ```typescript import { createYoga, createSchema } from 'graphql-yoga'; const yoga = createYoga({ schema: createSchema({ typeDefs: /* GraphQL */ ` type Query { greetings: String } `, resolvers: { Query: { greetings: () => 'Hello' } }, }), }); test('greetings', async () => { const response = await yoga.fetch('http://yoga/graphql', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ query: '{ greetings }' }), }); const result = await response.json(); expect(result.data.greetings).toBe('Hello'); }); ``` The URL `http://yoga/graphql` is a placeholder - `yo