fix: restore timeout error name (#28408)
Fixes https://github.com/microsoft/playwright/issues/28404
This commit is contained in:
parent
35c2633013
commit
92a0d24069
|
|
@ -18,11 +18,17 @@ import type { SerializedError } from '@protocol/channels';
|
|||
import { isError } from '../utils';
|
||||
import { parseSerializedValue, serializeValue } from '../protocol/serializers';
|
||||
|
||||
export class TimeoutError extends Error {}
|
||||
export class TimeoutError extends Error {
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
this.name = 'TimeoutError';
|
||||
}
|
||||
}
|
||||
|
||||
export class TargetClosedError extends Error {
|
||||
constructor(cause?: string) {
|
||||
super(cause || 'Target page, context or browser has been closed');
|
||||
this.name = 'TargetClosedError';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,3 +50,8 @@ test('should not print timed out error message when page closes', async ({ page
|
|||
expect(stripAnsi(error.message)).toContain('expect.toHaveText with timeout 100000ms');
|
||||
expect(stripAnsi(error.message)).not.toContain('Timed out');
|
||||
});
|
||||
|
||||
test('should have timeout error name', async ({ page }) => {
|
||||
const error = await page.waitForSelector('#not-found', { timeout: 1 }).catch(e => e);
|
||||
expect(error.name).toBe('TimeoutError');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -454,7 +454,7 @@ for (const useIntermediateMergeReport of [false, true] as const) {
|
|||
`begin {\"title\":\"page.setContent\",\"category\":\"pw:api\"}`,
|
||||
`end {\"title\":\"page.setContent\",\"category\":\"pw:api\"}`,
|
||||
`begin {\"title\":\"page.click(input)\",\"category\":\"pw:api\"}`,
|
||||
`end {\"title\":\"page.click(input)\",\"category\":\"pw:api\",\"error\":{\"message\":\"Error: page.click: Timeout 1ms exceeded.\\nCall log:\\n \\u001b[2m- waiting for locator('input')\\u001b[22m\\n\",\"stack\":\"<stack>\",\"location\":\"<location>\",\"snippet\":\"<snippet>\"}}`,
|
||||
`end {\"title\":\"page.click(input)\",\"category\":\"pw:api\",\"error\":{\"message\":\"TimeoutError: page.click: Timeout 1ms exceeded.\\nCall log:\\n \\u001b[2m- waiting for locator('input')\\u001b[22m\\n\",\"stack\":\"<stack>\",\"location\":\"<location>\",\"snippet\":\"<snippet>\"}}`,
|
||||
`begin {\"title\":\"After Hooks\",\"category\":\"hook\"}`,
|
||||
`begin {\"title\":\"fixture: page\",\"category\":\"fixture\"}`,
|
||||
`end {\"title\":\"fixture: page\",\"category\":\"fixture\"}`,
|
||||
|
|
|
|||
Loading…
Reference in a new issue