Replies: 4 comments 4 replies
-
If you mean smth like below, I think it should work fine. Some overhead with restarting cypress several times for each e2e-test app, but it should pay off with e2e tests granularity. If you manage to run these e2e tests in parallel on different runners without side effects, it can be faster than running a single monolithic e2e application. In addition to e2e applications, you will have to implement at least one more shared library, e.g. {
...
"app": {
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"architect": {
...
},
"prefix": "app",
"projectType": "application",
"root": "apps/app",
"sourceRoot": "apps/app/src",
"tags": ["scope:app", "type:application"]
},
"app-e2e": {
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"architect": {
"e2e": {
"builder": "@nrwl/cypress:cypress",
"configurations": {
"production": {
"devServerTarget": "app:serve:production"
}
},
"options": {
"cypressConfig": "apps/app-e2e/cypress.json",
"devServerTarget": "app:serve",
"tsConfig": "apps/app-e2e/tsconfig.e2e.json"
}
},
...
},
"implicitDependencies": ["app"],
"projectType": "application",
"root": "apps/app-e2e",
"sourceRoot": "apps/app-e2e/src",
"tags": ["scope:app-e2e", "type:e2e"]
},
...
"feature-one": {
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"architect": {
...
},
"prefix": "app",
"projectType": "library",
"root": "libs/feature-one",
"sourceRoot": "libs/feature-one/src",
"tags": ["scope:feature-one", "type:feature"]
},
"feature-one-e2e": {
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"architect": {
"e2e": {
"builder": "@nrwl/cypress:cypress",
"configurations": {
"production": {
"devServerTarget": "app:serve:production"
}
},
"options": {
"cypressConfig": "apps/feature-one-e2e/cypress.json",
"devServerTarget": "app:serve",
"tsConfig": "apps/feature-one-e2e/tsconfig.e2e.json"
}
},
...
},
"implicitDependencies": ["feature-one"],
"projectType": "application",
"root": "apps/feature-one-e2e",
"sourceRoot": "apps/feature-one-e2e/src",
"tags": ["scope:feature-one-e2e", "type:e2e"]
},
...
"feature-two": {
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"architect": {
...
},
"prefix": "app",
"projectType": "library",
"root": "libs/feature-two",
"sourceRoot": "libs/feature-two/src",
"tags": ["scope:feature-two", "type:feature"]
},
"feature-two-e2e": {
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"architect": {
"e2e": {
"builder": "@nrwl/cypress:cypress",
"configurations": {
"production": {
"devServerTarget": "app:serve:production"
}
},
"options": {
"cypressConfig": "apps/feature-two-e2e/cypress.json",
"devServerTarget": "app:serve",
"tsConfig": "apps/feature-two-e2e/tsconfig.e2e.json"
}
},
...
},
"implicitDependencies": ["feature-two"],
"projectType": "application",
"root": "apps/feature-two-e2e",
"sourceRoot": "apps/feature-two-e2e/src",
"tags": ["scope:feature-two-e2e", "type:e2e"]
},
} |
Beta Was this translation helpful? Give feedback.
-
Nowadays it is possible to put feature-specific e2e-tests in your feature-library. You can use the generator for this. |
Beta Was this translation helpful? Give feedback.
-
Hi there, We're currently using Nx with an Angular(18.2.13) app that consumes multiple feature libraries, each of which depends on shared component libraries. Our E2E tests (written in Cypress 13.17.0) currently live in a single E2E app, covering all feature libraries. We’d like to optimize our CI pipeline by running only the E2E tests relevant to the affected modules when changes are introduced. Specifically, if a developer modifies a particular feature module, we want to detect that and trigger only the automated E2E tests for that module instead of running the full suite. Could you provide guidance on: How to configure our Nx workspace to run Cypress E2E tests for affected modules only? |
Beta Was this translation helpful? Give feedback.
-
You should always trust and use "NX affected" which the NX-toolset provides. A well-know saying is "don't fight the framework". We don't need to make use of tags for detect and/or triggering of tasks. The NX-framework does provide support for adding "tags" (in the project.json files), but this is (mostly) for ensuring correct workspace architecture. For instance "data-access"-libraries should (probably) not depend on ui/component-libraries. NX has eslint-rules to enforce this: You can choose to have a subset of E2E-tests to run in the CI-pipeline for each app. And to use the complete set of E2E-tests to run at another time. Although i don't make use of that. One thing which is important to think about that this needs to be selected by a command line parameter, for instance: If you would have i18n translation json files, then ideally each library will have it's own set of translation json files. If you would change a translation, this would make your library affected and trigger the library-specific E2E tests. Some examples:
|
Beta Was this translation helpful? Give feedback.
-
Currently we have a single app (Angular) consuming a bunch of feature libs which in turn consume component libraries we have written.
When we initially created the app project with Nx we got an e2e app auto generated for us, and in there we have been adding our test suites (Cypress). These suites cover all the various feature libs that the main app depends on.
With nx affected commands, we can of course ensure we only rebuild and unit test parts of the code base affected by changes being introduced.
Rather than having a single e2e app with all of our feature test suites in, is it practical to split these out into separate feature e2e apps with implicit dependencies on the feature libs? That way when we run nx affected with a target of e2e we run the minimum set of test suites needed to help scale out the development workflow. We could still keep a general e2e app for more involved user work flows, e.g. multi feature operations.
Has this kind of thing been asked before? Are there any dangers/pitfalls in implementing this kind of approach you can foresee?
Beta Was this translation helpful? Give feedback.
All reactions