Skip to content

applicationRef undefined in nest e2e tests #74

@lays147

Description

@lays147

Hello,
I'm using nestjs-prisma in an application, and I have an e2e test failing when an exception is launched because the applicationRef inside this lib is undefined.

Steps to reproduce:

  • Write an e2e test where you expect an exception to be raised using the findFirstOrThrow inside a nest service and call it through the controller.

Expected behavior:

The test passes without issues.

What is happening:

The exception is properly raised, however, the applicationRef is undefined making the test hang with:

    TypeError: Cannot read properties of undefined (reading 'isHeadersSent')

      at PrismaClientExceptionFilter.catch (node_modules/@nestjs/core/exceptions/base-exception-filter.js:27:29)
      at PrismaClientExceptionFilter.catchClientKnownRequestError (node_modules/nestjs-prisma/lib/prisma-client-exception.filter.ts:88:6)
      at PrismaClientExceptionFilter.catch (node_modules/nestjs-prisma/lib/prisma-client-exception.filter.ts:69:4)
      at ExceptionsHandler.invokeCustomFilters (node_modules/@nestjs/core/exceptions/exceptions-handler.js:33:26)
      at ExceptionsHandler.next (node_modules/@nestjs/core/exceptions/exceptions-handler.js:13:18)
      at node_modules/@nestjs/core/router/router-proxy.js:13:35

This issue does not happen in runtime.

Here is a thread on the NestJS discord server discussing about this bug.

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