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

@cypress/schematic: Can not use a config file and automatic port from dev server #29756

Open
fidian opened this issue Jun 26, 2024 · 0 comments
Labels
npm: @cypress/schematic @cypress/schematic package issues type: unexpected behavior User expected result, but got another

Comments

@fidian
Copy link

fidian commented Jun 26, 2024

Current behavior

The baseUrl can be retrieved from the dev server's config (see #21555, #21629). However, this logic is only allowed if there is no config file (see https://github.com/cypress-io/cypress/blob/develop/npm/cypress-schematic/src/builders/cypress/index.ts#L89).

Desired behavior

I run my Angular tests on a server with many concurrent builds running at a time. Angular supports picking a random, unused port for the dev server when specifying --port 0 or using the same in angular.json. This does get passed through to the builder's devServerBaseUrl correctly.

Our tests also employ a custom logger and custom browser selection, which requires that we use a config file to do proper detection on each system. The presence of the custom config eliminates the possibility of automatically setting baseUrl from devServerBaseUrl. Also, there's nothing we can get in the custom config that exposes information about the dev server's configuration, so we can't add a line into that config to make this work.

Test code to reproduce

Set up an Angular build without baseUrl specified then add configFile to the options in angular.json.

Cypress Version

13.12.0

Node version

20.14.0

Operating System

Various Linux systems (distro-independent)

Debug Logs

No response

Other

I do not know why this code has the if condition around it that checks for the presence of configFile instead of possibly checking for baseUrl.

  if (userOptions.configFile === undefined) {
    options.config = { e2e: { baseUrl: userOptions.devServerBaseUrl as string } }
  }

I would propose the following, or some variant:

  if (!options.config) {
    options.config = {};
  }

  if (!options.config.e2e) {
    options.config.e2e = {};
  }

  if (!options.config.e2e.baseUrl) {
    options.config.e2e.baseUrl = userOptions.devServerBaseUrl as string;
  }

Alternately, exposing userOptions would allow the end user to do this for themselves.

@jennifer-shehane jennifer-shehane added npm: @cypress/angular @cypress/angular package issues npm: @cypress/schematic @cypress/schematic package issues type: unexpected behavior User expected result, but got another and removed npm: @cypress/angular @cypress/angular package issues labels Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
npm: @cypress/schematic @cypress/schematic package issues type: unexpected behavior User expected result, but got another
Projects
None yet
Development

No branches or pull requests

2 participants