From 586f7466df8e776c929097017e27376301ca326c Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Tue, 20 Dec 2022 08:57:47 +0100 Subject: [PATCH] fix target url in error feedback --- src/setup-page.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/setup-page.ts b/src/setup-page.ts index da9cbdf8..26d9582d 100644 --- a/src/setup-page.ts +++ b/src/setup-page.ts @@ -23,7 +23,8 @@ const sanitizeURL = (url: string) => { }; export const setupPage = async (page: Page) => { - const targetURL = new URL('iframe.html', process.env.TARGET_URL).toString(); + const targetURL = process.env.TARGET_URL; + const viewMode = process.env.VIEW_MODE || 'story'; const renderedEvent = viewMode === 'docs' ? 'docsRendered' : 'storyRendered'; const { packageJson } = await readPackageUp(); @@ -40,7 +41,8 @@ export const setupPage = async (page: Page) => { ); } - await page.goto(targetURL, { waitUntil: 'load' }).catch((err) => { + const iframeURL = new URL('iframe.html', process.env.TARGET_URL).toString(); + await page.goto(iframeURL, { waitUntil: 'load' }).catch((err) => { if (err.message?.includes('ERR_CONNECTION_REFUSED')) { const errorMessage = `Could not access the Storybook instance at ${targetURL}. Are you sure it's running?\n\n${err.message}`; throw new Error(errorMessage);