microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
66.39k stars 3.63k forks source link

[Question] Custom assertion timeout run out #29233

Closed ChrystianC closed 8 months ago

ChrystianC commented 8 months ago

System info

   test('should open abc', async ({ page }) => {
        test.setTimeout(120 * 1000);
        await broadcastEditor.goto(
            '/Content/Edit?id=227548201&isEvent=true')
        const contentContainer = page.locator('.editor-content');
        let shouldScroll = true;
        while (shouldScroll) {
            await expect(page).toMatchScreenshot({timeout: 15 * 1000});
            shouldScroll = await contentContainer.evaluate((node) => {
                const { clientHeight, scrollHeight, scrollTop } = node;
                node.scrollBy(0, clientHeight);
                return scrollHeight - scrollTop - clientHeight > 1;
            });
        }
    });

Function toMatchScreenshot

export const expect = baseExpect.extend<{
  toMatchScreenshot(page: Page, options?: MatchScreenshotOptions): Promise<{
    message: () => string;
    pass: boolean;
  }>,
}>({
  async toMatchScreenshot(page, { hide = [], ...options } = {}) {
    for (const locator of hide) {
      await locator.evaluateAll((nodes) => {
        for (const node of nodes) {
          node.style.visibility = 'hidden';
        }
      });
    }
    await baseExpect(page).toHaveScreenshot(options);
    return { message: () => '', pass: true };
  },
});

Question

pavelfeldman commented 8 months ago

If you believe this is a Playwright bug, please follow the BUG template and provide a scenario I could reproduce locally (without external dependencies and pages specific to your app)

pavelfeldman commented 8 months ago

Closing as per above.