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

Cannot use cypress port 0 to auto-assign a port if the devServerTarget is @nrwl/web:file-server #16684

Closed
dsjellz opened this issue May 1, 2023 · 3 comments · Fixed by #16917
Assignees
Labels
outdated scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx type: bug

Comments

@dsjellz
Copy link

dsjellz commented May 1, 2023

Current Behavior

When configuring the @nrwl/cypress:cypress executor to use port 0, to randomly assign a port, the port is not respected if the devServerTarget uses the @nrwl/web:file-server executor. The devServerTarget start successfully, it just doesn't pass that port back to Cypress.

Starting up http-server, serving dist/apps/port-passthrough

http-server version: 14.1.1

http-server settings: 
CORS: true
Cache: -1 seconds
Connection Timeout: 120 seconds
Directory Listings: visible
AutoIndex: visible
Serve GZIP Files: false
Serve Brotli Files: false
Default File Extension: none

Available on:
  http://localhost:8081
Hit CTRL-C to stop the server
Cypress could not verify that this server is running:

  > http://localhost:0

We are verifying this server because it has been configured as your baseUrl.

Cypress automatically waits until your server is accessible before running tests.

We will try connecting to it 3 more times...
We will try connecting to it 2 more times...
We will try connecting to it 1 more time...

Cypress failed to verify that your server is running.

Please start this server and then run Cypress again.

Expected Behavior

I would expect the underlying devServerTarget to use the same port that the Cypress executor is expecting.

GitHub Repo

https://github.com/dsjellz/cypress-port-passthrough

Steps to Reproduce

  1. Execute nx run port-passthrough-e2e:e2e and the devServerTarget will run on port 54895 (or something)
  2. Execute nx run port-passthrough-e2e:e2e:ci and the devServerTarget will run on port 8080 (regardless if that port is in use).

Nx Report

Node : 16.14.2
   OS   : darwin arm64
   npm  : 8.5.0
   
   nx                      : 15.9.3
   @nrwl/js                : 15.9.3
   @nrwl/jest              : 15.9.3
   @nrwl/linter            : 15.9.3
   @nrwl/workspace         : 15.9.3
   @nrwl/angular           : 15.9.3
   @nrwl/cli               : 15.9.3
   @nrwl/cypress           : 15.9.3
   @nrwl/devkit            : 15.9.3
   @nrwl/eslint-plugin-nx  : 15.9.3
   @nrwl/tao               : 15.9.3
   @nrwl/web               : 15.9.3
   @nrwl/webpack           : 15.9.3
   typescript              : 4.9.5

Failure Logs

No response

Additional Information

No response

@AgentEnder AgentEnder added the scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx label May 1, 2023
@barbados-clemens barbados-clemens self-assigned this May 3, 2023
@dsjellz
Copy link
Author

dsjellz commented May 9, 2023

Getting this to work against @nrwl/angular:module-federation-dev-server also does not work. You can get the serve task for the underlying remotes to start on a random port just fine, but relaying that random port to the host application at run time is another story.

@barbados-clemens
Copy link
Contributor

@dsjellz could you update the repo with an module federation issue you're seeing. I believe to have figured out the issue with the port value not being passed back via @nx/web:file-server, but want to confirm it also works for the module federation issue you've come across.

@github-actions
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 Jun 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants