From 1794ae33f159863f99e65218ae0071c71ecb5e6b Mon Sep 17 00:00:00 2001 From: Michael Brevard Date: Tue, 20 Aug 2024 14:51:44 +0300 Subject: [PATCH] test: begin waiting for response before events --- test/basic.test.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/basic.test.ts b/test/basic.test.ts index 226cad13a5..bf252a4162 100644 --- a/test/basic.test.ts +++ b/test/basic.test.ts @@ -2700,15 +2700,17 @@ describe('lazy import components', () => { expect(await page.locator('body').getByText('This should be visible at first with events!').all()).toHaveLength(2) const component = await page.locator('#lazyevent') const rect = (await component.boundingBox())! - await page.mouse.move(rect.x + rect.width / 2, rect.y + rect.height / 2) - await page.waitForResponse(response => + const resp = page.waitForResponse(response => response.status() === 200 && response.text().then(text => text.includes('This shouldn\'t be visible at first with events!')), ) + await page.mouse.move(rect.x + rect.width / 2, rect.y + rect.height / 2) + await resp expect(await page.locator('body').getByText('This shouldn\'t be visible at first with events!').all()).toHaveLength(1) - await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight)) - await page.waitForResponse(response => + const resp2 = page.waitForResponse(response => response.status() === 200 && response.text().then(text => text.includes('This shouldn\'t be visible at first with viewport!')), ) + await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight)) + await resp2 expect(await page.locator('body').getByText('This shouldn\'t be visible at first with viewport!').all()).toHaveLength(1) await page.close() })