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 · 1 comment
Labels
npm: @cypress/schematic @cypress/schematic package issues stale no activity on this issue for a long period 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
@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label Dec 26, 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 stale no activity on this issue for a long period type: unexpected behavior User expected result, but got another
Projects
None yet
Development

No branches or pull requests

3 participants