diff --git a/e2e/node/src/node.test.ts b/e2e/node/src/node.test.ts index f776ac8e01cacd..095c83c9ea6d26 100644 --- a/e2e/node/src/node.test.ts +++ b/e2e/node/src/node.test.ts @@ -428,6 +428,52 @@ ${jslib}(); checkFilesExist(`dist/apps/_should_keep.txt`); }, 120000); + it('should support generating projects with the new name and root format', () => { + const appName = uniq('app1'); + const libName = uniq('@my-org/lib1'); + + runCLI( + `generate @nx/node:app ${appName} --project-name-and-root-format=as-provided --no-interactive` + ); + + // check files are generated without the layout directory ("apps/") and + // using the project name as the directory when no directory is provided + checkFilesExist(`${appName}/src/main.ts`); + // check build works + expect(runCLI(`build ${appName}`)).toContain( + `Successfully ran target build for project ${appName}` + ); + // check tests pass + const appTestResult = runCLI(`test ${appName}`); + expect(appTestResult).toContain( + `Successfully ran target test for project ${appName}` + ); + + // assert scoped project names are not supported when --project-name-and-root-format=derived + expect(() => + runCLI( + `generate @nx/node:lib ${libName} --buildable --project-name-and-root-format=derived --no-interactive` + ) + ).toThrow(); + + runCLI( + `generate @nx/node:lib ${libName} --buildable --project-name-and-root-format=as-provided --no-interactive` + ); + + // check files are generated without the layout directory ("libs/") and + // using the project name as the directory when no directory is provided + checkFilesExist(`${libName}/src/index.ts`); + // check build works + expect(runCLI(`build ${libName}`)).toContain( + `Successfully ran target build for project ${libName}` + ); + // check tests pass + const libTestResult = runCLI(`test ${libName}`); + expect(libTestResult).toContain( + `Successfully ran target test for project ${libName}` + ); + }, 500_000); + describe('NestJS', () => { it('should have plugin output if specified in `tsPlugins`', async () => { newProject();