Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Commit

Permalink
Fix hardcoded dev server URL
Browse files Browse the repository at this point in the history
  • Loading branch information
shilman committed Aug 20, 2023
1 parent 06751b5 commit dd14c9d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ This will execute the test you have just written alongside the E2E tests from be

## TODO

- [ ] Dev server URL is hard-coded
- [ ] `beforeMount` / `afterMount` hooks unimplemented
- [ ] How to use this alongside play function
- [ ] How to use this alongside Playwright E2E
13 changes: 10 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,20 @@ const fixtures: Fixtures<
await use(page);
},

mount: async ({ page }, use) => {
mount: async ({ page }, use, info) => {
await use(async (storyId: StoryOrExport, args?: Args) => {
boundCallbacksForMount = [];
if (args) wrapFunctions(args, page, boundCallbacksForMount);

if (typeof storyId !== 'string') return {} as MountResult;
await page.goto('http://localhost:6006/iframe.html?id=' + storyId);

const config = (info as any)._configInternal.config as PlaywrightTestConfig;
if (!config?.webServer) throw new Error('webServer config is missing');
const server = Array.isArray(config.webServer) ? config.webServer[0] : config.webServer;
const url = server.url || `http://localhost:${server.port}`;

await page.goto(join(url, 'iframe.html'));

await page.evaluate(
async ({ storyId, args }) => {
const channel = __STORYBOOK_ADDONS_CHANNEL__;
Expand Down Expand Up @@ -137,7 +144,7 @@ const defineConfig = (config: PlaywrightTestConfig) =>
},
webServer: {
command: 'npm run storybook',
url: 'http://127.0.0.1:6006',
url: 'http://localhost:6006',
reuseExistingServer: true,
...config.webServer,
},
Expand Down

0 comments on commit dd14c9d

Please sign in to comment.