From f52861e3bffc240689f6fe51cd48eca3695cf92c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leosvel=20P=C3=A9rez=20Espinosa?= Date: Mon, 14 Aug 2023 11:23:02 +0100 Subject: [PATCH] chore(angular): add e2e tests --- e2e/angular-core/src/projects.test.ts | 51 +++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/e2e/angular-core/src/projects.test.ts b/e2e/angular-core/src/projects.test.ts index 3945a4b0eb693b..fa33887509d6d2 100644 --- a/e2e/angular-core/src/projects.test.ts +++ b/e2e/angular-core/src/projects.test.ts @@ -350,4 +350,55 @@ describe('Angular Projects', () => { ); expect(buildOutput).toContain('Successfully ran target build'); }); + + it('should generate project with name and directory as provided when --project-name-and-root-format=as-provided', () => { + const lib1 = uniq('lib1'); + runCLI( + `generate @nx/angular:lib ${lib1} --directory=shared --buildable --project-name-and-root-format=as-provided` + ); + + // check files are generated without the layout directory ("libs/") and + // in the directory provided (no project name appended) + checkFilesExist('shared/src/index.ts'); + // check project name is as provided (no prefixed directory name) + expect(runCLI(`build ${lib1}`)).toContain( + `Successfully ran target build for project ${lib1}` + ); + // check tests pass + const testResult = runCLI(`test ${lib1}`); + expect(testResult).toContain( + `Successfully ran target test for project ${lib1}` + ); + }, 500_000); + + it('should support generating with a scoped project name when --project-name-and-root-format=as-provided', () => { + const scopedLib = uniq('@my-org/lib1'); + + // assert scoped project names are not supported when --project-name-and-root-format=derived + expect(() => + runCLI( + `generate @nx/angular:lib ${scopedLib} --buildable --project-name-and-root-format=derived` + ) + ).toThrow(); + + runCLI( + `generate @nx/angular:lib ${scopedLib} --buildable --project-name-and-root-format=as-provided` + ); + + // check files are generated without the layout directory ("libs/") and + // using the project name as the directory when no directory is provided + checkFilesExist( + `${scopedLib}/src/index.ts`, + `${scopedLib}/src/lib/${scopedLib.split('/')[1]}.module.ts` + ); + // check build works + expect(runCLI(`build ${scopedLib}`)).toContain( + `Successfully ran target build for project ${scopedLib}` + ); + // check tests pass + const testResult = runCLI(`test ${scopedLib}`); + expect(testResult).toContain( + `Successfully ran target test for project ${scopedLib}` + ); + }, 500_000); });