Skip to content

Commit

Permalink
cherry-pick(#14264): chore: more testing-friendly trace (#14276)
Browse files Browse the repository at this point in the history
SHA 432c52d

Co-authored-by: Pavel Feldman <[email protected]>
  • Loading branch information
aslushnikov and pavelfeldman authored May 19, 2022
1 parent baa6aa9 commit 14782d7
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions packages/playwright-test/src/mount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,29 @@ export const fixtures: Fixtures<PlaywrightTestArgs & PlaywrightTestOptions & { m
if (!_ctPage.page || _ctPage.hash !== hash) {
if (_ctPage.page)
await _ctPage.page.close();
_ctPage.page = await (browser as any)._wrapApiCall(async () => {
const page = await (browser as any)._wrapApiCall(async () => {
const page = await browser.newPage();
await page.addInitScript('navigator.serviceWorker.register = () => {}');
await page.exposeFunction('__pw_dispatch', (ordinal: number, args: any[]) => {
boundCallbacksForMount[ordinal](...args);
});
await page.goto(process.env.PLAYWRIGHT_VITE_COMPONENTS_BASE_URL!);
return page;
});
}, true);
_ctPage.page = page;
_ctPage.hash = hash;
await use(page);
} else {
await (_ctPage.page as any)._resetForReuse();
await (_ctPage.page.context() as any)._resetForReuse();
await _ctPage.page.goto('about:blank');
await _ctPage.page.setViewportSize(viewport || { width: 1280, height: 800 });
const page = _ctPage.page;
await (page as any)._wrapApiCall(async () => {
await (page as any)._resetForReuse();
await (page.context() as any)._resetForReuse();
await page.goto('about:blank');
await page.setViewportSize(viewport || { width: 1280, height: 800 });
await page.goto(process.env.PLAYWRIGHT_VITE_COMPONENTS_BASE_URL!);
}, true);
await use(page);
}

const page = _ctPage.page!;
await page.goto(process.env.PLAYWRIGHT_VITE_COMPONENTS_BASE_URL!);
await use(page);
},

mount: async ({ page }, use) => {
Expand Down

0 comments on commit 14782d7

Please sign in to comment.