Registry / testing / apollo-test-utils

apollo-test-utils

JSON →
library0.3.2jsnpmunverified

apollo-test-utils is a rudimentary JavaScript package specifically designed to facilitate testing with Apollo Client version 1.x. Released with a low version number (0.3.2), it primarily offered functions like `mockNetworkInterfaceWithSchema` to mock the network interface, a core architectural concept prevalent in Apollo Client's early iterations. This package is no longer maintained, with its last commit dating back to 2017, and is completely incompatible with Apollo Client versions 2.x and above. The original `apollo-client` v1, for which this package was intended, has been superseded by `@apollo/client`. Modern testing approaches for Apollo Client, which has since evolved through several major releases, leverage `@apollo/client/testing` for React components (e.g., `MockedProvider`) or directly mock `ApolloLink` instances for headless client testing. Developers should consider `apollo-test-utils` abandoned and migrate to current official Apollo testing utilities for any active projects.

npm install apollo-test-utils
INSTALL
IMPORT
SIG · APOLLO-TEST-UTILS
A
apollo-test-utils
testingjavascriptv0.3.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

mockNetworkInterfaceWithSchema
import { mockNetworkInterfaceWithSchema } from 'apollo-test-utils';
const { mockNetworkInterfaceWithSchema } = require('apollo-test-utils');
This package primarily exports `mockNetworkInterfaceWithSchema` for Apollo Client v1. Modern Apollo Client (v2+) uses different testing utilities like `MockedProvider` or `ApolloLink` mocks.
ApolloClient
import ApolloClient from 'apollo-client';
import { ApolloClient } from '@apollo/client';
The quickstart code uses `apollo-client` v1. Modern Apollo Client is imported from `@apollo/client` (named export).
gql
import gql from 'graphql-tag';
import { gql } from '@apollo/client';
In older Apollo Client setups, `graphql-tag` was a common way to parse GraphQL queries. Modern Apollo Client versions typically export `gql` directly from `@apollo/client`.

Demonstrates mocking an Apollo Client v1 network interface with a GraphQL schema for basic query testing.

import ApolloClient from 'apollo-client'; import gql from 'graphql-tag'; import { makeExecutableSchema, addMockFunctionsToSchema } from 'graphql-tools'; import { mockNetworkInterfaceWithSchema } from 'apollo-test-utils'; const typeDefs = ` type User { id: Int name: String } type Query { user: User } `; const schema = makeExecutableSchema({ typeDefs }); addMockFunctionsToSchema({ schema }); const mockNetworkInterface = mockNetworkInterfaceWithSchema({ schema }); const client = new ApolloClient({ networkInterface: mockNetworkInterface, }); client.query({ query: gql`{ user { name } }`, }).then(result => { console.log('Query Result:', result.data.user.name); });
Debug
Known issues
breakingThis package is only compatible with `apollo-client` v1.x. It is not compatible with `apollo-client` v2.x, v3.x, or v4.x due to fundamental architectural changes, including the deprecation of the `networkInterface` concept. The package is abandoned and receives no further updates.
fix
For testing Apollo Client v2+, v3+, or v4+ applications, use the official `@apollo/client/testing` package (e.g., `MockedProvider` for React components) or mock `ApolloLink` instances.
affects: >=0.3.2
deprecatedThe package `apollo-test-utils` has been abandoned since 2017 and is no longer maintained. Using it in new projects or with modern Apollo Client versions will lead to incompatibility issues.
fix
Migrate to current official Apollo Client testing solutions. For React, `@apollo/client/testing` provides `MockedProvider`. For client-agnostic GraphQL testing, consider `@apollo/graphql-testing-library`.
affects: >=0.3.2
gotchaThis package was developed before widespread adoption of ECMAScript Modules (ESM). Using it in modern JavaScript environments or with module bundlers that heavily rely on ESM might lead to unexpected CommonJS/ESM interoperability issues.
fix
If strictly needing to run this legacy code, ensure your build setup supports transparent CommonJS interoperability for older packages, but a full migration to modern testing libraries is strongly recommended.
affects: >=0.3.2
Errors
Common errors & fixes
TypeError: client.query is not a function
Attempting to use `apollo-test-utils` with `ApolloClient` v2+ where the `networkInterface` concept and the associated `query` method signature have changed significantly or are missing.
fix
This package is incompatible with Apollo Client v2+. Update your testing strategy to use `@apollo/client/testing` or `ApolloLink` based mocks for modern Apollo Client versions.
Error: Cannot find module 'apollo-test-utils' or 'apollo-client'
The package is either not installed, or you are attempting to use it in a project that has fundamentally diverged from its original dependencies (e.g., trying to use it with `@apollo/client` instead of `apollo-client` v1).
fix
Ensure `apollo-test-utils` and `apollo-client@^1.0.0` are correctly installed. More importantly, consider if you are trying to use an abandoned package with a modern setup. If so, switch to `@apollo/client/testing` for modern Apollo Client testing.
Upgrade
Version history
0.3.2latest on npm
Audit
Dependencies
apollo-clientrequiredRequired peer dependency for runtime, specifically targets version ^1.0.0.
Agent activity
40 hits · last 30 days
node
36
OpenAI (training)
1
Resources
apollo-test-utils — npm install apollo-test-utils · libregistry