question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Transitioning to Nx fails when current Angular repo has Cypress installed

See original GitHub issue

Current Behavior

When I try to migrate existing Angular 13 project which has Cypress e2e tests, I see the below error

Make sure the testproject.architect.e2e.options.protractorConfig is valid or the testproject project is removed from angular.json.
An e2e project was specified but undefined could not be found.
Your workspace could not be converted into an Nx Workspace because of the above error.
An e2e project was specified but undefined could not be found.

Expected Behavior

The migration should work as expected

Steps to Reproduce

  1. Create new Angular project through Angular CLi
  2. Add Cypress to it
  3. Then try to migrate the project with command ng add @nrwl/workspace or ng add @nrwl/workspace --preserveAngularCLILayout

angular.json

        "e2e": {
          "builder": "@cypress/schematic:cypress",
          "options": {
            "devServerTarget": "testproject:serve",
            "watch": true,
            "headless": true,
            "browser": "chrome"
          },
          "configurations": {
            "production": {
              "devServerTarget": "testproject:serve:production"
            }
          }
        },

and folder structure looks like below

Screen Shot 2022-01-05 at 1 40 45 AM

Failure Logs

Make sure the testproject.architect.e2e.options.protractorConfig is valid or the testproject project is removed from angular.json.
An e2e project was specified but undefined could not be found.
Your workspace could not be converted into an Nx Workspace because of the above error.
An e2e project was specified but undefined could not be found.

Environment

>  NX  Report complete - copy this into the issue template

  Node : 16.13.1
  OS   : darwin x64
  npm  : 8.1.2
  
  nx : 13.1.3
  @nrwl/angular : undefined
  @nrwl/cli : 13.4.3
  @nrwl/cypress : undefined
  @nrwl/devkit : 13.1.3
  @nrwl/eslint-plugin-nx : undefined
  @nrwl/express : undefined
  @nrwl/jest : 13.4.3
  @nrwl/linter : 13.4.3
  @nrwl/nest : undefined
  @nrwl/next : undefined
  @nrwl/node : undefined
  @nrwl/nx-cloud : undefined
  @nrwl/react : undefined
  @nrwl/react-native : undefined
  @nrwl/schematics : undefined
  @nrwl/tao : 13.1.3
  @nrwl/web : undefined
  @nrwl/workspace : 13.4.3
  @nrwl/storybook : undefined
  @nrwl/gatsby : undefined
  typescript : 4.5.4
  rxjs : 7.4.0
  ---------------------------------------
  Community plugins:
         @angular/animations: 13.1.1
         @angular/cdk: 13.1.1
         @angular/common: 13.1.1
         @angular/compiler: 13.1.1
         @angular/core: 13.1.1
         @angular/forms: 13.1.1
         @angular/material: 13.1.1
         @angular/platform-browser: 13.1.1
         @angular/platform-browser-dynamic: 13.1.1
         @angular/platform-server: 13.1.1
         @angular/router: 13.1.1
         @datorama/akita: 7.0.1
         @angular-devkit/build-angular: 13.1.2
         @angular-eslint/builder: 13.0.1
         @angular-eslint/schematics: 13.0.1
         @angular/cli: 13.1.2
         @angular/compiler-cli: 13.1.1
         @cypress/schematic: 1.6.0



Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
leosvelperezcommented, Feb 28, 2022

This was fixed on https://github.com/nrwl/nx/pull/9105 and it will be released in an upcoming version.

1reaction
johnbwoodruffcommented, Jan 26, 2022

There is a workaround to this. In your angular.json file, remove the e2e block of configuration and save the file. Then, run the ng add @nrwl/workspace command. It will complete the migration successfully. You can then add the e2e block back in and make any changes necessary with the newly converted project.

The problem here is that none of the cypress migrations are performed and you will have to perform those manually. See the manual instructions on how to do this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Migrating an Angular CLI project to Nx
This command will install the correct version of Nx based on your Angular version. This will enable you to use the Nx CLI...
Read more >
Trying to run nx.dev e2e tests I get the error "Cannot find ...
As the error states, the module cypress/package.json is missing, ... it along the way in this project as it takes a while to...
Read more >
nrwl-nx/community - Gitter
I'm trying to setup cypress for running e2e tests in an existing Angular app. It seams that this app has to be transformed...
Read more >
@Nrwl/Community
What is a general recommendation on adding NGRX to NX Angular workspace? ... I haven't used cypress very extensively before switching to nx....
Read more >
Angular CLI and Nx — Why?. In this blog post, I'll present a…
Nx CLI. Nx, on the other hand, generates an Angular workspace with the following setup: Angular Application; Jest for Unit Testing; Cypress for ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found