0

We have a growing project that already has 50+ Library folders (will probably end up with 5 - 10 times this, maybe much more).
Each Library folder has Storybook stories, Jest specs, Angular components, services, NgrxStores etc. The Cypress E2E tests are generated outside the libs folder, this is initially very confusing and does not really make any sense.

Is it possible to alter the location of these Cypress projects to somewhere custom? Eg The Cypress E2E folder for a Library in the fictional: Libs -> CommonUI -> DropdownList Library would be: Libs -> CommonUI -> DropdownList-e2e

Is this possible? or any other solutions? Thanks.

cuznerdexter
  • 586
  • 5
  • 21

1 Answers1

0

Nx doesn't necessarily enforce a folder structure. So you're free to move any of the folders where ever you wish, you'll just have to update all the relevant paths in the workspace.json or angular.json file. You'll also need to update some entries in the jest.config.js file.

You could use the @nrwl/workspace:move schematic that will automatically rewrite the entries in the above named files for you.

To test this, move the e2e app into the directory you want to place it in, and change the entry in the workspace.json or angular.json file for that project.

You would need to change these entries:

"contractors-e2e": {
      "root": "apps/contractors-e2e", <<<< 1
      "sourceRoot": "apps/contractors-e2e/src", <<<< 2
      "projectType": "application",
      "targets": {
        "e2e": {
          "executor": "@nrwl/cypress:cypress",
          "options": {
            "cypressConfig": "apps/contractors-e2e/cypress.json", <<<< 3
            "tsConfig": "apps/contractors-e2e/tsconfig.e2e.json", <<<< 4
            "devServerTarget": "contractors-app:serve:development"
          },
C.OG
  • 6,236
  • 3
  • 20
  • 38
  • Thanks for this example, it helps a great deal. I will try this approach and see if it works for us. With hundreds of libraries this will become painful. Would be good if Angular-Cli had options to customize this at generation time. – cuznerdexter Jul 12 '21 at 16:56