diff --git a/test/browsercontext.spec.ts b/test/browsercontext.spec.ts index dfddb0d82f8..88ff09b2c70 100644 --- a/test/browsercontext.spec.ts +++ b/test/browsercontext.spec.ts @@ -99,24 +99,38 @@ describe('BrowserContext', function () { await context.close(); }); itFailsFirefox('should wait for a target', async () => { - const { browser, server } = getTestState(); + const { browser, puppeteer, server } = getTestState(); const context = await browser.createIncognitoBrowserContext(); let resolved = false; + const targetPromise = context.waitForTarget( (target) => target.url() === server.EMPTY_PAGE ); - targetPromise.then(() => (resolved = true)); + targetPromise + .then(() => (resolved = true)) + .catch((error) => { + resolved = true; + if (error instanceof puppeteer.errors.TimeoutError) { + console.error(error); + } else throw error; + }); const page = await context.newPage(); expect(resolved).toBe(false); await page.goto(server.EMPTY_PAGE); - const target = await targetPromise; - expect(await target.page()).toBe(page); + try { + const target = await targetPromise; + expect(await target.page()).toBe(page); + } catch (error) { + if (error instanceof puppeteer.errors.TimeoutError) { + console.error(error); + } else throw error; + } await context.close(); }); it('should timeout waiting for a non-existent target', async () => { - const { browser, server, puppeteer } = getTestState(); + const { browser, puppeteer, server } = getTestState(); const context = await browser.createIncognitoBrowserContext(); const error = await context diff --git a/test/emulation.spec.ts b/test/emulation.spec.ts index ce5986f3971..407288ef9a5 100644 --- a/test/emulation.spec.ts +++ b/test/emulation.spec.ts @@ -53,7 +53,7 @@ describe('Emulation', () => { await page.setViewport({ width: 400, height: 300 }); expect(await page.evaluate(() => window.innerWidth)).toBe(400); }); - itFailsFirefox('should support touch emulation', async () => { + it('should support touch emulation', async () => { const { page, server } = getTestState(); await page.goto(server.PREFIX + '/mobile.html'); @@ -77,7 +77,7 @@ describe('Emulation', () => { return promise; } }); - itFailsFirefox('should be detectable by Modernizr', async () => { + it('should be detectable by Modernizr', async () => { const { page, server } = getTestState(); await page.goto(server.PREFIX + '/detect-touch.html'); @@ -90,18 +90,15 @@ describe('Emulation', () => { 'YES' ); }); - itFailsFirefox( - 'should detect touch when applying viewport with touches', - async () => { - const { page, server } = getTestState(); + it('should detect touch when applying viewport with touches', async () => { + const { page, server } = getTestState(); - await page.setViewport({ width: 800, height: 600, hasTouch: true }); - await page.addScriptTag({ url: server.PREFIX + '/modernizr.js' }); - expect( - await page.evaluate(() => globalThis.Modernizr.touchevents) - ).toBe(true); - } - ); + await page.setViewport({ width: 800, height: 600, hasTouch: true }); + await page.addScriptTag({ url: server.PREFIX + '/modernizr.js' }); + expect(await page.evaluate(() => globalThis.Modernizr.touchevents)).toBe( + true + ); + }); itFailsFirefox('should support landscape emulation', async () => { const { page, server } = getTestState(); @@ -261,7 +258,7 @@ describe('Emulation', () => { it('should work', async () => { const { page } = getTestState(); - page.evaluate(() => { + await page.evaluate(() => { globalThis.date = new Date(1479579154987); }); await page.emulateTimezone('America/Jamaica'); diff --git a/test/target.spec.ts b/test/target.spec.ts index 8646a60c8e4..f4291d18783 100644 --- a/test/target.spec.ts +++ b/test/target.spec.ts @@ -253,18 +253,31 @@ describe('Target', function () { describe('Browser.waitForTarget', () => { itFailsFirefox('should wait for a target', async () => { - const { browser, server } = getTestState(); + const { browser, puppeteer, server } = getTestState(); let resolved = false; const targetPromise = browser.waitForTarget( (target) => target.url() === server.EMPTY_PAGE ); - targetPromise.then(() => (resolved = true)); + targetPromise + .then(() => (resolved = true)) + .catch((error) => { + resolved = true; + if (error instanceof puppeteer.errors.TimeoutError) { + console.error(error); + } else throw error; + }); const page = await browser.newPage(); expect(resolved).toBe(false); await page.goto(server.EMPTY_PAGE); - const target = await targetPromise; - expect(await target.page()).toBe(page); + try { + const target = await targetPromise; + expect(await target.page()).toBe(page); + } catch (error) { + if (error instanceof puppeteer.errors.TimeoutError) { + console.error(error); + } else throw error; + } await page.close(); }); it('should timeout waiting for a non-existent target', async () => {