diff --git a/test/browser/fixtures/timeout-hooks/hooks-timeout.test.ts b/test/browser/fixtures/timeout-hooks/hooks-timeout.test.ts index 430a831cc..dddb7a101 100644 --- a/test/browser/fixtures/timeout-hooks/hooks-timeout.test.ts +++ b/test/browser/fixtures/timeout-hooks/hooks-timeout.test.ts @@ -3,46 +3,41 @@ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, onTes describe.runIf(server.provider === 'playwright')('timeouts are failing correctly', () => { it('click on non-existing element fails', async () => { - await new Promise(r => setTimeout(r, 100)) await page.getByRole('code').click() - }, 500) + }, 150) it('expect.element on non-existing element fails', async () => { await expect.element(page.getByRole('code')).toBeVisible() - }, 500) + }, 150) describe('beforeEach', () => { beforeEach(async () => { - await new Promise(r => setTimeout(r, 100)) await page.getByTestId('non-existing').click() - }, 500) + }, 150) it('skipped', () => {}) }) describe('afterEach', () => { afterEach(async () => { - await new Promise(r => setTimeout(r, 100)) await page.getByTestId('non-existing').click() - }, 500) + }, 150) it('skipped', () => {}) }) describe('beforeAll', () => { beforeAll(async () => { - await new Promise(r => setTimeout(r, 100)) await page.getByTestId('non-existing').click() - }, 500) + }, 150) it('skipped', () => {}) }) describe('afterAll', () => { afterAll(async () => { - await new Promise(r => setTimeout(r, 100)) await page.getByTestId('non-existing').click() - }, 500) + }, 150) it('skipped', () => {}) }) @@ -50,34 +45,30 @@ describe.runIf(server.provider === 'playwright')('timeouts are failing correctly describe('onTestFinished', () => { it('fails', ({ onTestFinished }) => { onTestFinished(async () => { - await new Promise(r => setTimeout(r, 100)) await page.getByTestId('non-existing').click() - }, 500) + }, 150) }) it('fails global', () => { onTestFinished(async () => { - await new Promise(r => setTimeout(r, 100)) await page.getByTestId('non-existing').click() - }, 500) + }, 150) }) }) describe('onTestFailed', () => { it('fails', ({ onTestFailed }) => { onTestFailed(async () => { - await new Promise(r => setTimeout(r, 100)) await page.getByTestId('non-existing').click() - }, 500) + }, 150) expect.unreachable() }) it('fails global', () => { onTestFailed(async () => { - await new Promise(r => setTimeout(r, 100)) await page.getByTestId('non-existing').click() - }, 500) + }, 150) expect.unreachable() }) diff --git a/test/browser/specs/runner.test.ts b/test/browser/specs/runner.test.ts index b3531742e..1a0eb73a0 100644 --- a/test/browser/specs/runner.test.ts +++ b/test/browser/specs/runner.test.ts @@ -290,11 +290,15 @@ test('in-source tests run correctly when filtered', async () => { expect(stdout).toContain(`Tests ${instances.length} passed`) }) -test.runIf(provider.name === 'playwright')('timeout hooks', async () => { +test.runIf(provider.name === 'playwright')('timeout hooks', async ({ onTestFailed }) => { const { stderr } = await runBrowserTests({ root: './fixtures/timeout-hooks', }) + onTestFailed(() => { + console.error(stderr) + }) + const lines = stderr.split('\n') const timeoutErrorsIndexes = [] lines.forEach((line, index) => { @@ -425,122 +429,122 @@ test.runIf(provider.name === 'playwright')('timeout hooks', async () => { } else { expect(snapshot).toMatchInlineSnapshot(` - " FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > afterAll - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:44:45 + " FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > afterAll + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:39:45 + + FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > afterEach > skipped + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:23:45 + + FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > beforeAll + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:31:45 + + FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > beforeEach > skipped + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:15:45 + + FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > click on non-existing element fails + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:6:33 - FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > afterEach > skipped - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:26:45 - - FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > beforeAll - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:35:45 - - FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > beforeEach > skipped - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:17:45 - - FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > click on non-existing element fails - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:7:33 - - FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > onTestFailed > fails - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:70:47 - - FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > onTestFailed > fails global - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:79:47 - - FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > onTestFinished > fails - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:54:47 - - FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > onTestFinished > fails global - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:61:47 - - FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > afterAll - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:44:45 - - FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > afterEach > skipped - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:26:45 - - FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > beforeAll - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:35:45 - - FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > beforeEach > skipped - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:17:45 - - FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > click on non-existing element fails - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:7:33 - - FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > onTestFailed > fails - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:70:47 - - FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > onTestFailed > fails global - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:79:47 - - FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > onTestFinished > fails - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:54:47 - - FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > onTestFinished > fails global - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:61:47 - - FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > afterAll - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:44:51 - - FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > afterEach > skipped - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:26:51 - - FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > beforeAll - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:35:51 - - FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > beforeEach > skipped - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:17:51 - - FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > click on non-existing element fails - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:7:39 - - FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > onTestFailed > fails - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:70:53 - - FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > onTestFailed > fails global - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:79:53 - - FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > onTestFinished > fails - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:54:53 + FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > onTestFailed > fails + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:62:47 + + FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > onTestFailed > fails global + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:70:47 - FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > onTestFinished > fails global - TimeoutError: locator.click: Timeout exceeded. - ❯ hooks-timeout.test.ts:61:53" - `) + FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > onTestFinished > fails + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:48:47 + + FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > onTestFinished > fails global + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:54:47 + + FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > afterAll + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:39:45 + + FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > afterEach > skipped + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:23:45 + + FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > beforeAll + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:31:45 + + FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > beforeEach > skipped + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:15:45 + + FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > click on non-existing element fails + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:6:33 + + FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > onTestFailed > fails + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:62:47 + + FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > onTestFailed > fails global + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:70:47 + + FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > onTestFinished > fails + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:48:47 + + FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > onTestFinished > fails global + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:54:47 + + FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > afterAll + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:39:51 + + FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > afterEach > skipped + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:23:51 + + FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > beforeAll + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:31:51 + + FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > beforeEach > skipped + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:15:51 + + FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > click on non-existing element fails + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:6:39 + + FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > onTestFailed > fails + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:62:53 + + FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > onTestFailed > fails global + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:70:53 + + FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > onTestFinished > fails + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:48:53 + + FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > onTestFinished > fails global + TimeoutError: locator.click: Timeout exceeded. + ❯ hooks-timeout.test.ts:54:53" + `) } // page.getByRole('code').click() expect(stderr).toContain('locator.click: Timeout') // playwright error is proxied from the server to the client and back correctly expect(stderr).toContain('waiting for locator(\'[data-vitest="true"]\').contentFrame().getByRole(\'code\')') - expect(stderr).toMatch(/hooks-timeout.test.ts:7:(33|39)/) + expect(stderr).toMatch(/hooks-timeout.test.ts:6:(33|39)/) // await expect.element().toBeVisible() expect(stderr).toContain('Cannot find element with locator: getByRole(\'code\')') - expect(stderr).toMatch(/hooks-timeout.test.ts:11:(49|61)/) + expect(stderr).toMatch(/hooks-timeout.test.ts:10:(49|61)/) }, 120_000 * 3)