Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

applicationRef undefined in nest e2e tests #74

Open
lays147 opened this issue Aug 10, 2023 · 1 comment
Open

applicationRef undefined in nest e2e tests #74

lays147 opened this issue Aug 10, 2023 · 1 comment

Comments

@lays147
Copy link

lays147 commented Aug 10, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants