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

fix(storybook): return baseUrl from storybook and use in cypress #14306

Merged
merged 1 commit into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/cypress/src/executors/cypress/cypress.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ async function* startDevServer(
for await (const output of await runExecutor<{
success: boolean;
baseUrl?: string;
info?: { port: number; baseUrl?: string };
}>(
{ project, target, configuration },
// @NOTE: Do not forward watch option if not supported by the target dev server,
Expand All @@ -183,7 +184,15 @@ async function* startDevServer(
)) {
if (!output.success && !opts.watch)
throw new Error('Could not compile application files');
yield opts.baseUrl || (output.baseUrl as string);
if (
!opts.baseUrl &&
!output.baseUrl &&
!output.info.baseUrl &&
output.info.port
) {
output.baseUrl = `http://localhost:${output.info.port}`;
}
yield opts.baseUrl || output.baseUrl || output.info.baseUrl;
}
}

Expand Down
15 changes: 13 additions & 2 deletions packages/storybook/src/executors/storybook/storybook.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import { CommonNxStorybookConfig } from '../models';
export default async function* storybookExecutor(
options: CLIOptions & CommonNxStorybookConfig,
context: ExecutorContext
): AsyncGenerator<{ success: boolean; info?: { port: number } }> {
): AsyncGenerator<{
success: boolean;
info?: { port: number; baseUrl?: string };
}> {
const storybook7 = isStorybookV7();
storybookConfigExistsCheck(options.configDir, context.projectName);
if (storybook7) {
Expand All @@ -22,7 +25,15 @@ export default async function* storybookExecutor(
buildOptions,
storybook7
);
yield { success: true, info: { port: result.port } };
yield {
success: true,
info: {
port: result.port,
baseUrl: `${options.https ? 'https' : 'http'}://${
options.host ?? 'localhost'
}:${result.port}`,
},
};
await new Promise<{ success: boolean }>(() => {});
} else {
// TODO (katerina): Remove when Storybook 7
Expand Down