Skip to content

apollo-server-testing throws error: Unable to create test client (TypeError: Cannot read property 'bind' of undefined) #5111

@bigfish

Description

@bigfish

Using apollo-server & apollo-server-testing 2.22.2

Following documentation to setup an integration test here https://www.apollographql.com/docs/apollo-server/testing/testing/

I get the error when I run jest:

TypeError: Cannot read property 'bind' of undefined

     104 |         });
     105 |         // console.log(server);
   > 106 |         const { query } = createTestClient(server);
         |                           ^
     107 |
     108 |         const res = await query({
     109 |           query: GET_ROUTES

     at createTestClient (node_modules/apollo-server-testing/src/createTestClient.ts:31:52)
     at Object.<anonymous> (spec/routesResolver.spec.js:106:27)

Looking at the referenced source code, it is attempting to bind a function named executeOperation. Apparently this doesn't exist?

export default (server: ApolloServerBase): ApolloServerTestClient => {
  const executeOperation = server.executeOperation.bind(server);

Is there some mismatch between the testing library and the server?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions