Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(angular): support application builder for cypress component testing #20214

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/angular/plugins/component-testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ ${e.stack ? e.stack : e}`
const buildTarget = getBuildableTarget(ctContext);

if (!buildTarget.project && !graph.nodes?.[buildTarget.project]?.data) {
throw new Error(stripIndents`Unable to find project configuration for build target.
throw new Error(stripIndents`Unable to find project configuration for build target.
Project Name? ${buildTarget.project}
Has project config? ${!!graph.nodes?.[buildTarget.project]?.data}`);
}
Expand Down Expand Up @@ -295,8 +295,8 @@ Note: this may fail, setting the correct 'sourceRoot' for ${buildContext.project
}

function withSchemaDefaults(options: any): BrowserBuilderSchema {
if (!options.main) {
throw new Error('Missing executor options "main"');
if (!options.main && !options.browser) {
throw new Error('Missing executor options "main" and "browser"');
}
if (!options.index) {
throw new Error('Missing executor options "index"');
Expand All @@ -322,6 +322,7 @@ function withSchemaDefaults(options: any): BrowserBuilderSchema {
options.outputHashing ??= 'none';
options.progress ??= true;
options.scripts ??= [];
options.main = options.main ??= options.browser;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

options.main ??= options.browser;

I'd also move the options check after this, so you only have 1 condition/branch:

if (!options.main) {
  throw new Error('Missing executor options "main" and "browser"');
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, removed the check here: #20382

I like the co-location of the checks that throw errors more then having only a single condition/branch.


return options;
}
Expand Down