after upgrading to Jest version 29.4.3 any second Jest (nestJS) integration test in suite will fail

20 Views Asked by At

I am using Jest for testing on my NestJS (on Nx mono repo) project.

As part of an Nx upgrade (migration) - from version 13 to version 18 - Jest version was updated from ^26.6.3 to 29.4.3. (NestJS packages were also upgraded)

After the upgrade any second test in an integration target test suite will fail. Error reported is related to the GraphQL module in NestJS. Seems like an error inializing the module (GraphQLModule.forRoot).

The Application is initialized in a beforeAll in every test suite. First spec file will pass as expected and any spec file which follows will fail to initialize the NestJS app with the following error:

Cannot determine a GraphQL output type for the "maxTokens". Make sure your class is decorated with an appropriate decorator.

The application itself is working properly when I run nx serve. There's nothing really wrong with the GQL filed types.

Even when running jest randomized it will always pass on first .spec test suite and fail on the second one.

I am using @nx/jest:jest executor to run a test directory:

"integration": {
      "executor": "@nx/jest:jest",
      "options": {
        "jestConfig": "apps/hepius/server/test/integration/jest.config.js"
      }
}

I tried the runInBand Jest option I tried running jest with the the Nx executor (npx jest)

0

There are 0 best solutions below