{"id":12815,"library":"apollo-test-utils","title":"Apollo Client Test Utilities (Deprecated)","description":"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.","status":"abandoned","version":"0.3.2","language":"javascript","source_language":"en","source_url":"https://github.com/apollographql/apollo-test-utils","tags":["javascript","typescript"],"install":[{"cmd":"npm install apollo-test-utils","lang":"bash","label":"npm"},{"cmd":"yarn add apollo-test-utils","lang":"bash","label":"yarn"},{"cmd":"pnpm add apollo-test-utils","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required peer dependency for runtime, specifically targets version ^1.0.0.","package":"apollo-client","optional":false}],"imports":[{"note":"This package primarily exports `mockNetworkInterfaceWithSchema` for Apollo Client v1. Modern Apollo Client (v2+) uses different testing utilities like `MockedProvider` or `ApolloLink` mocks.","wrong":"const { mockNetworkInterfaceWithSchema } = require('apollo-test-utils');","symbol":"mockNetworkInterfaceWithSchema","correct":"import { mockNetworkInterfaceWithSchema } from 'apollo-test-utils';"},{"note":"The quickstart code uses `apollo-client` v1. Modern Apollo Client is imported from `@apollo/client` (named export).","wrong":"import { ApolloClient } from '@apollo/client';","symbol":"ApolloClient","correct":"import ApolloClient from 'apollo-client';"},{"note":"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`.","wrong":"import { gql } from '@apollo/client';","symbol":"gql","correct":"import gql from 'graphql-tag';"}],"quickstart":{"code":"import ApolloClient from 'apollo-client';\nimport gql from 'graphql-tag';\nimport { makeExecutableSchema, addMockFunctionsToSchema } from 'graphql-tools';\nimport { mockNetworkInterfaceWithSchema } from 'apollo-test-utils';\n\nconst typeDefs = `\n    type User {\n      id: Int\n      name: String\n    }\n\n    type Query {\n      user: User\n    }\n  `;\n\nconst schema = makeExecutableSchema({ typeDefs });\naddMockFunctionsToSchema({ schema });\n\nconst mockNetworkInterface = mockNetworkInterfaceWithSchema({ schema });\n\nconst client = new ApolloClient({\n  networkInterface: mockNetworkInterface,\n});\n\nclient.query({\n  query: gql`{ user { name } }`,\n}).then(result => {\n  console.log('Query Result:', result.data.user.name);\n});","lang":"javascript","description":"Demonstrates mocking an Apollo Client v1 network interface with a GraphQL schema for basic query testing."},"warnings":[{"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.","message":"This 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.","severity":"breaking","affected_versions":">=0.3.2"},{"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`.","message":"The 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.","severity":"deprecated","affected_versions":">=0.3.2"},{"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.","message":"This 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.","severity":"gotcha","affected_versions":">=0.3.2"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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.","cause":"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.","error":"TypeError: client.query is not a function"},{"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.","cause":"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).","error":"Error: Cannot find module 'apollo-test-utils' or 'apollo-client'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null}