Skip to content

Testkit fails to execute query #2225

@Brian-McBride

Description

@Brian-McBride

Testkit not executing query (or mutations) using testkit.execute()

Problem

I'm having issues with testkit even running resolvers. Like a todo app:

    const app = testkit.testModule(todosGraphqlModule);
    expect(app.schema.getQueryType()).toBeDefined();
    expect(app.schema.getMutationType()).toBeDefined();

    const graphResult = await testkit.execute(app, {
      document: gql`
        query getTodo($id: ID!) {
          id
          title
        }
      `,
      variableValues: {
        id: 'someId',
      },
    });

    console.log(graphResult);  // output is:  { data {} }

Seems pretty simple. If I run the code in my app, the resolvers run as expected. But running this in Jest I always get { data {} } as a result, and the resolvers are never executed.

Reproduceable problem

Stackblitz

https://stackblitz.com/edit/node-mnkhc1?file=src/modules/users/users.module.spec.ts

Example repo

https://github.com/Brian-McBride/graphql-modules-testing-example

The schema link

The module link

The test is here:

Expected behavior

The response from the test should run the query and return its value.

Environment:

  • OS: OSX 12.4
  • "graphql-modules": "^2.1.0",:
  • NodeJS: v18.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions