Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does nrwl nx create a separate e2e project for each app?

When creating a new nx workspace (i.e. with create-nx-workspace) and then generating an app (with ng g app) it creates an app folder inside the apps folder (so far so good) and also another app-e2e folder, also inside the apps folder. In my mind it would make much more sense to create an e2e folder inside the app folder, next to the src folder, since the e2e tests should belong to that specific app and also it won't clutter the apps folder that way.

So what is the reasoning behind this convention?

Thanks a lot!

like image 992
AlexanderSchuster Avatar asked Aug 09 '18 09:08

AlexanderSchuster


1 Answers

What is the reasoning behind this convention?

It turns out that it's actually due to the Angular 6 CLI. Nx just uses the built in angular schematics. I wasn't aware of this initially, but you can verify this behavior by creating a new app with ng new app1 and then ng generate application app2 inside of app1. app1 is created with the regular structure, while app2 and a sibling app2-e2e are created inside a default projects directory within app1.

Initially, I had the same question as you. I have been manually restructuring every newly generated app in my nx workspace so that the e2e folder is inside of its respective app folder. This led me to create a feature request in the nx repo. The underlying Angular CLI 6 convention was explained to me after I opened a PR for this functionality.

like image 117
Chris Newman Avatar answered Mar 06 '23 03:03

Chris Newman