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

New NestJS E2E Boilerplate Failing Tests #16498

Closed
Elte156 opened this issue Apr 24, 2023 · 4 comments
Closed

New NestJS E2E Boilerplate Failing Tests #16498

Elte156 opened this issue Apr 24, 2023 · 4 comments
Labels
outdated scope: node Issues related to Node, Express, NestJS support for Nx stale type: bug

Comments

@Elte156
Copy link

Elte156 commented Apr 24, 2023

Current Behavior

When installing a new NestJS application, an E2E app is also created. Running the E2E tests shows a few warnings and ultimately failed tests.

Expected Behavior

Running the boilerplate NestJS E2E tests should pass.

GitHub Repo

No response

Steps to Reproduce

  1. npm install -D @nrwl/nest
  2. nx g @nrwl/nest:app my-nest-app
  3. npx nx run my-nest-app-e2e:e2e

Nx Report

Node : 16.19.1
   OS   : darwin x64
   npm  : 8.19.3
   
   nx                      : 15.9.2
   @nrwl/js                : 15.9.2
   @nrwl/jest              : 15.9.2
   @nrwl/linter            : 15.9.2
   @nrwl/workspace         : 15.9.2
   @nrwl/angular           : 15.9.2
   @nrwl/cli               : 15.9.2
   @nrwl/cypress           : 15.9.2
   @nrwl/devkit            : 15.9.2
   @nrwl/eslint-plugin-nx  : 15.9.2
   @nrwl/nest              : 15.9.2
   @nrwl/node              : 15.9.2
   @nrwl/tao               : 15.9.2
   @nrwl/webpack           : 15.9.2
   typescript              : 4.9.5

Failure Logs

XXX$ npx nx run my-nest-app-e2e:e2e

> nx run my-nest-app-e2e:e2e

● Validation Warning:

  Unknown option "coverageDirectory" with value "../../coverage/my-nest-app-e2e" was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

Determining test suites to run...ts-jest[ts-jest-transformer] (WARN) Define `ts-jest` config under `globals` is deprecated. Please do
transform: {
    <transform_regex>: ['ts-jest', { /* ts-jest config goes here in Jest */ }],
},

Setting up...

 FAIL   my-nest-app-e2e  apps/my-nest-app-e2e/src/my-nest-app/my-nest-app.spec.ts
  GET /api
    ✕ should return a message (31 ms)

  ● GET /api › should return a message

    connect ECONNREFUSED 127.0.0.1:3333

      at Function.Object.<anonymous>.AxiosError.from (../../node_modules/axios/lib/core/AxiosError.js:89:14)
      at RedirectableRequest.handleRequestError (../../node_modules/axios/lib/adapters/http.js:577:25)
      at ClientRequest.eventHandlers.<computed> (../../node_modules/follow-redirects/index.js:14:24)

    Cause:
    connect ECONNREFUSED 127.0.0.1:3333



Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        0.644 s
Ran all test suites.

Tearing down...


 ———————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Ran target e2e for project my-nest-app-e2e (5s)
 
    ✖    1/1 failed
    ✔    0/1 succeeded [0 read from cache]

Additional Information

No response

@AgentEnder AgentEnder added the scope: node Issues related to Node, Express, NestJS support for Nx label Apr 24, 2023
@Elte156
Copy link
Author

Elte156 commented Apr 26, 2023

I believe there are a number of things at fault here:

  1. Port mismatches
    1. Generated apps/store-api/src/main.ts uses port 3000
    2. Generated apps/store/proxy.conf.json uses port 3333
    3. Generated apps/store-api-e2e/src/support/test-setup.ts uses port 3333
  2. Trying to run a NestJS E2E target requires the actual NestJS project to be served on port 3333
    1. This requires some orchestration that Nx does not provide out of the box
    2. You'd manually have to start the NestJs project and have it listen on port 3333
    3. Then you could run the E2E tests for it
    4. This comment node-app nestjs e2e test module #1098 (comment) suggests to add devServerTarget as a configurable option so Nx can orchestrate

@creadicted
Copy link

creadicted commented Jun 3, 2023

Since @FurlanLuka implemented the e2e module in #14805 most likely there is an intended approach in to this. Maybe it's just missing documentation. I agree that when generated, the test should not fail, but I am missing a working approach to get the main app running from within the global-setup.ts. At least, that's my (Most likely wrong) expected behavior.

Copy link

github-actions bot commented Dec 1, 2023

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: node Issues related to Node, Express, NestJS support for Nx stale type: bug
Projects
None yet
Development

No branches or pull requests

3 participants