Skip to content

Commit

Permalink
cleanup(angular): add e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leosvelperez committed Aug 14, 2023
1 parent e9116e7 commit f0424db
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions e2e/angular-core/src/projects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

0 comments on commit f0424db

Please sign in to comment.