nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
22.63k stars 2.26k forks source link

baseUrl can still not be changed in cypress e2e #18176

Open wiegell opened 11 months ago

wiegell commented 11 months ago

Current Behavior

This issue is still present: https://github.com/nrwl/nx/issues/1614

The baseurl is not picked up regardless of being set as a cli flag or in cypress.config.ts. Defaulting to 4200 (angular app) no matter what. Setting the --port flag can serve the app at that port, but cy.visit("/") still goes to 4200.

Expected Behavior

Should go to correct url/port

GitHub Repo

No response

Steps to Reproduce

see above

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 18.15.0
   OS     : darwin arm64
   yarn   : 3.5.1
   Hasher : Native

   nx                      : 16.1.4
   @nrwl/js                : 16.1.4
   @nx/jest                : 16.1.4
   @nrwl/linter            : 16.1.4
   @nrwl/workspace         : 16.1.4
   @nrwl/angular           : 16.1.4
   @nrwl/cypress           : 16.1.4
   @nrwl/devkit            : 16.1.4
   @nrwl/eslint-plugin-nx  : 16.1.4
   typescript              : 5.0.4
   ---------------------------------------
   Community plugins:
   @ngrx/effects        : 16.0.1
   @ngrx/entity         : 16.0.1
   @ngrx/router-store   : 16.0.1
   @ngrx/store          : 16.0.1
   @ngrx/store-devtools : 16.0.1
   apollo-angular       : 5.0.0
   ng-mocks             : 14.10.0
   nx-stylelint         : 15.0.0

Failure Logs

No response

Operating System

Additional Information

No response

barbados-clemens commented 11 months ago

the baseUrl being set in the cypress.config.ts file most likely won't be picked up unless the devServerTarget doesn't return a baseUrl.

The order is executor option baseUrl then devserver returned baseUrl. Since the angular dev server you're using always returns that value cypress config won't get picked up.

So setting the executor option should work (via cli or project.json)

what command are you running and what does the project.json for the e2e target look like?

github-actions[bot] commented 2 months ago

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! 🙏

leosvelperez commented 1 week ago

I can't reproduce the issue.

Using the reported Nx version (16.1.4) with the following cypress.config.ts:

import { defineConfig } from 'cypress';
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';

export default defineConfig({
  e2e: {
    ...nxE2EPreset(__dirname),
    baseUrl: 'http://localhost:4201',
  },
});

And the following serve target:

"serve": {
  "executor": "@angular-devkit/build-angular:dev-server",
  "configurations": {
    "production": {
      "browserTarget": "app1:build:production"
    },
    "development": {
      "browserTarget": "app1:build:development",
      "port": 4201
    }
  },
  "defaultConfiguration": "development"
}

The e2e tests work as expected. They test against the correct baseUrl. I also confirmed it works in more recent versions of Nx.

Please provide a repo where the issue you're facing can be reproduced.

github-actions[bot] commented 3 days ago

This issue has been automatically marked as stale because no reproduction was provided within 7 days. Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue. Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues. This issue will be closed in 21 days if a reproduction is not provided. If a reproduction has been provided, please reply to keep it active. Thanks for being a part of the Nx community! 🙏