diff --git a/e2e/angular-core/src/projects.test.ts b/e2e/angular-core/src/projects.test.ts index 3945a4b0eb693b..b5fca5495f6402 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('hhhhhhshould 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('hhhhhhshould 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); });