mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(waitForEvent): include timeout value in the timeout message (#10738)
This commit is contained in:
parent
26e0c6122c
commit
516360be5f
@ -201,7 +201,7 @@ export class AndroidDevice extends ChannelOwner<channels.AndroidDeviceChannel> i
|
||||
const timeout = this._timeoutSettings.timeout(typeof optionsOrPredicate === 'function' ? {} : optionsOrPredicate);
|
||||
const predicate = typeof optionsOrPredicate === 'function' ? optionsOrPredicate : optionsOrPredicate.predicate;
|
||||
const waiter = Waiter.createForEvent(this._channel, event);
|
||||
waiter.rejectOnTimeout(timeout, `Timeout while waiting for event "${event}"`);
|
||||
waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded while waiting for event "${event}"`);
|
||||
if (event !== Events.AndroidDevice.Close)
|
||||
waiter.rejectOnEvent(this, Events.AndroidDevice.Close, new Error('Device closed'));
|
||||
const result = await waiter.waitForEvent(this, event, predicate as any);
|
||||
|
||||
@ -267,7 +267,7 @@ export class BrowserContext extends ChannelOwner<channels.BrowserContextChannel>
|
||||
const timeout = this._timeoutSettings.timeout(typeof optionsOrPredicate === 'function' ? {} : optionsOrPredicate);
|
||||
const predicate = typeof optionsOrPredicate === 'function' ? optionsOrPredicate : optionsOrPredicate.predicate;
|
||||
const waiter = Waiter.createForEvent(this._channel, event);
|
||||
waiter.rejectOnTimeout(timeout, `Timeout while waiting for event "${event}"`);
|
||||
waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded while waiting for event "${event}"`);
|
||||
if (event !== Events.BrowserContext.Close)
|
||||
waiter.rejectOnEvent(this, Events.BrowserContext.Close, new Error('Context closed'));
|
||||
const result = await waiter.waitForEvent(this, event, predicate as any);
|
||||
|
||||
@ -103,7 +103,7 @@ export class ElectronApplication extends ChannelOwner<channels.ElectronApplicati
|
||||
const timeout = this._timeoutSettings.timeout(typeof optionsOrPredicate === 'function' ? {} : optionsOrPredicate);
|
||||
const predicate = typeof optionsOrPredicate === 'function' ? optionsOrPredicate : optionsOrPredicate.predicate;
|
||||
const waiter = Waiter.createForEvent(this._channel, event);
|
||||
waiter.rejectOnTimeout(timeout, `Timeout while waiting for event "${event}"`);
|
||||
waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded while waiting for event "${event}"`);
|
||||
if (event !== Events.ElectronApplication.Close)
|
||||
waiter.rejectOnEvent(this, Events.ElectronApplication.Close, new Error('Electron application closed'));
|
||||
const result = await waiter.waitForEvent(this, event, predicate as any);
|
||||
|
||||
@ -475,7 +475,7 @@ export class WebSocket extends ChannelOwner<channels.WebSocketChannel> implement
|
||||
const timeout = this._page._timeoutSettings.timeout(typeof optionsOrPredicate === 'function' ? {} : optionsOrPredicate);
|
||||
const predicate = typeof optionsOrPredicate === 'function' ? optionsOrPredicate : optionsOrPredicate.predicate;
|
||||
const waiter = Waiter.createForEvent(this._channel, event);
|
||||
waiter.rejectOnTimeout(timeout, `Timeout while waiting for event "${event}"`);
|
||||
waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded while waiting for event "${event}"`);
|
||||
if (event !== Events.WebSocket.Error)
|
||||
waiter.rejectOnEvent(this, Events.WebSocket.Error, new Error('Socket error'));
|
||||
if (event !== Events.WebSocket.Close)
|
||||
|
||||
@ -383,7 +383,7 @@ export class Page extends ChannelOwner<channels.PageChannel> implements api.Page
|
||||
const waiter = Waiter.createForEvent(channel, event);
|
||||
if (logLine)
|
||||
waiter.log(logLine);
|
||||
waiter.rejectOnTimeout(timeout, `Timeout while waiting for event "${event}"`);
|
||||
waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded while waiting for event "${event}"`);
|
||||
if (event !== Events.Page.Crash)
|
||||
waiter.rejectOnEvent(this, Events.Page.Crash, new Error('Page crashed'));
|
||||
if (event !== Events.Page.Close)
|
||||
|
||||
@ -269,7 +269,7 @@ it.describe('pause', () => {
|
||||
'page.pause- XXms',
|
||||
'page.waitForEvent(console)',
|
||||
'waiting for event \"console\"',
|
||||
'error: Timeout while waiting for event \"console\"',
|
||||
'error: Timeout 1ms exceeded while waiting for event \"console\"',
|
||||
'page.pause',
|
||||
]);
|
||||
await recorderPage.click('[title="Resume"]');
|
||||
|
||||
@ -48,6 +48,7 @@ it('should respect timeout', async ({ page, playwright }) => {
|
||||
let error = null;
|
||||
await page.waitForEvent('request', { predicate: () => false, timeout: 1 }).catch(e => error = e);
|
||||
expect(error).toBeInstanceOf(playwright.errors.TimeoutError);
|
||||
expect(error.message).toContain('Timeout 1ms exceeded while waiting for event "request"');
|
||||
});
|
||||
|
||||
it('should respect default timeout', async ({ page, playwright }) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user