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

Injected HttpAdapterHost's http adapter is lost on testing module #12217

Closed
3 of 15 tasks
micalevisk opened this issue Aug 11, 2023 · 1 comment
Closed
3 of 15 tasks

Injected HttpAdapterHost's http adapter is lost on testing module #12217

micalevisk opened this issue Aug 11, 2023 · 1 comment
Labels
needs triage This issue has not been looked into

Comments

@micalevisk
Copy link
Member

micalevisk commented Aug 11, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

when injecting HttpAdapterHost, httpAdapter getter is returning undefined even tho the host does has ExpressAdapter instantiated on it

here's the print of httpAdapterHost value:

image

here's the print of httpAdapterHost.httpAdapter:

image

image

Testing module setup:

image

Minimum reproduction code

https://gitlab.com/micalevisk/nestjs-testing-http-adapter-host-issue

Steps to reproduce

git clone https://gitlab.com/micalevisk/nestjs-testing-http-adapter-host-issue
cd nestjs-testing-http-adapter-host-issue
npm ci
npm run test:e2e
# see the error

npm start 
# works fine

Expected behavior

the value of httpAdapterHost.httpAdapter of the injected HttpAdapterHost should be an instance of ExpressAdapter, not undefined. Like it is when using NestFactory.create()

Package

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

Other package

No response

NestJS version

10.1.3

Packages versions

[System Information]
OS Version     : Linux 6.2
NodeJS Version : v18.15.0
NPM Version    : 9.6.6 

[Nest CLI]
Nest CLI Version : 10.1.11 

[Nest Platform Information]
platform-express version : 10.1.3
schematics version       : 10.0.2
testing version          : 10.1.3
common version           : 10.1.3
core version             : 10.1.3
cli version              : 10.1.11

Node.js version

No response

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@kamilmysliwiec
Copy link
Member

#8076 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue has not been looked into
Projects
None yet
Development

No branches or pull requests

2 participants