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

Angular Schematic custom projectPath ignored #26402

Open
jfahrenkrug opened this issue Apr 3, 2023 · 0 comments
Open

Angular Schematic custom projectPath ignored #26402

jfahrenkrug opened this issue Apr 3, 2023 · 0 comments
Labels
E2E Issue related to end-to-end testing npm: @cypress/schematic @cypress/schematic package issues Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team.

Comments

@jfahrenkrug
Copy link

jfahrenkrug commented Apr 3, 2023

Current behavior

I have an Angular project. The package.json file is on the root level, but the actual Angular app is in a subfolder web. I'm trying to migrate from Protractor to Cypress using the cypress schematics.

The issue is this: I can't seem to get Cypress to use the web subfolder to look for its files. I'm setting projectPath (https://github.com/cypress-io/cypress/blob/develop/npm/cypress-schematic/src/builders/cypress/cypressBuilderOptions.ts#L17) to the absolute path of my web folder (as a test) but this line here always overrides that projectPath with the root path of the project: https://github.com/cypress-io/cypress/blob/develop/npm/cypress-schematic/src/builders/cypress/index.ts#L44

I might simply be doing something wrong, but I can't seem to figure out how to tell Cypress to use the subfolder instead of the root folder.

This the e2e entry in my angular.json:

        "e2e": {
          "builder": "@cypress/schematic:cypress",
          "options": {
            "devServerTarget": "sales-web:serve",
            "watch": true,
            "headless": false,
            "configFile": "web/cypress.config.ts",
            "projectPath": "/Users/johannes/Code/sales-web/web"
          },
          "configurations": {
            "production": {
              "devServerTarget": "sales-web:serve:production"
            }
          }
        }

Desired behavior

Cypress should respect the relative or absolute projectPath I set in angular.json.

Test code to reproduce

You can find the forked test project here: https://github.com/jfahrenkrug/cypress-angular-test-tiny
It includes basically a vanilla Angular 15 app. Cypress was added by running npx ng add @cypress/schematic. Notice how the actual Angular app and the cypress folder live in a subfolder called web. In angular.json, the e2e section looks like this:

"e2e": {
          "builder": "@cypress/schematic:cypress",
          "options": {
            "devServerTarget": "sales-web:serve",
            "watch": true,
            "headless": false,
            "configFile": "web/cypress.config.ts",
            "projectPath": "web"
          },
          "configurations": {
            "production": {
              "devServerTarget": "sales-web:serve:production"
            }
          }
        }

Notice howe projectPath is set to web. But when running npm run e2e, you get this error screen:

Screenshot 2023-04-03 at 4 40 16 PM

As you can see, it's looking in cypress/support/e2e, NOT in web/cypress/support/e2e.

Cypress Version

12.9.0

Node version

v16.18.0

Operating System

macOS 13.2.1

Debug Logs

No response

Other

No response

@jfahrenkrug jfahrenkrug changed the title Angular Schematic custom projectPath or workspaceRoot Angular Schematic custom projectPath ignored Apr 3, 2023
@jordanpowell88 jordanpowell88 removed their assignment Apr 13, 2023
@nagash77 nagash77 added E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. tools and removed routed-to-tools labels Apr 19, 2023
@jennifer-shehane jennifer-shehane added npm: @cypress/schematic @cypress/schematic package issues and removed tools labels Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E2E Issue related to end-to-end testing npm: @cypress/schematic @cypress/schematic package issues Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team.
Projects
None yet
Development

No branches or pull requests

5 participants