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

nx run my-app:e2e --testingType component does not work for an @nrwl/nx-generated project #63

Closed
rkrisztian opened this issue Jun 9, 2021 · 3 comments
Labels
cypress-angular enhancement New feature or request

Comments

@rkrisztian
Copy link

rkrisztian commented Jun 9, 2021

I've got an Angular 12 project set up with @nrwl/nx version 12.3.6. It has two projects: my-app (for the Angular app itself) + my-app-e2e (for the Cypress end-to-end tests). To add Cypress component testing too, I've followed the README:

npx ng add @jscutlery/cypress-angular

By the way, this adds the package as a regular dependency, instead of a dev dependency. Bug? Anyways, I've moved it into the dev dependencies, it shouldn't matter anyway.

npx ng g @jscutlery/cypress-angular:setup-ct --project my-app
npx ngcc

The following command failed: ❌

$ npx nx run my-app:e2e --testingType component
An unhandled exception occurred: Project target does not exist.
See "/tmp/ng-Wpsu5T/angular-errors.log" for further details.

The following command worked and executed the sample tests successfully: ✔

$ npx cypress open-ct --project apps/my-app

However, if I add the following to angular.json, I can fix the nx way like this:

{
  // ...
  "projects": {
    "my-app": {
      // ...
      "architect": {
        // ...
        "ct": {
          "builder": "@nrwl/cypress:cypress",
          "options": {
            "cypressConfig": "apps/my-app/cypress.json",
            "tsConfig": "apps/my-app/tsconfig.cypress.json",
            "devServerTarget": "",
            "testingType": "component"
          }
        }
      }
    }
    // ...
  }
}

Then the command simply becomes: ✔

$ npx nx run my-app:ct

I guess it makes sense to add something like this to the documentation or to the schematic?

@rkrisztian
Copy link
Author

This issue might be related to #49

@rkrisztian
Copy link
Author

I don't know if I should open a ticket about this, but in an @nwrl/nx-generated project, the Cypress video and screenshot paths are not configured for component tests by the schematic, I had to do it myself so that the videos are automatically git ignored:

rkrisztian/cypress-jest-test-project@2f18cd4#diff-ff33022ba6f5c96693402adef8688371518e9ddcf5b5f10cfa0605833709efd6

I'm wondering if we can pick up some Nx conventions here when use of Nx is detected.

@edbzn
Copy link
Member

edbzn commented Jun 25, 2021

Hi, sorry for the delay. I removed the mention of this Nx command in the doc because as you mentioned the workspace definition is not updated accordingly by the schematic. To make this feature, before we have to make the function updateProjectConfiguration compatible with regular AngularCLI, see: nrwl/nx#5678.

I don't know if I should open a ticket about this, but in an @nwrl/nx-generated project, the Cypress video and screenshot paths are not configured for component tests by the schematic, I had to do it myself so that the videos are automatically git ignored:

I think it's another issue, let's open a new ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cypress-angular enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants