mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: deprecate indirect error imports (#9072)
This commit is contained in:
parent
3675f168ef
commit
6ab823ef34
@ -120,18 +120,18 @@ sidebar_label: API
|
||||
|
||||
## Variables
|
||||
|
||||
| Variable | Description |
|
||||
| --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [connect](./puppeteer.connect.md) | |
|
||||
| [createBrowserFetcher](./puppeteer.createbrowserfetcher.md) | |
|
||||
| [DEFAULT_INTERCEPT_RESOLUTION_PRIORITY](./puppeteer.default_intercept_resolution_priority.md) | The default cooperative request interception resolution priority |
|
||||
| [defaultArgs](./puppeteer.defaultargs.md) | |
|
||||
| [devices](./puppeteer.devices.md) | A list of devices to be used with <code>page.emulate(options)</code>. Actual list of devices can be found in [src/common/DeviceDescriptors.ts](https://github.com/puppeteer/puppeteer/blob/main/src/common/DeviceDescriptors.ts). |
|
||||
| [errors](./puppeteer.errors.md) | <p>Puppeteer methods might throw errors if they are unable to fulfill a request. For example, <code>page.waitForSelector(selector[, options])</code> might fail if the selector doesn't match any nodes during the given timeframe.</p><p>For certain types of errors Puppeteer uses specific error classes. These classes are available via <code>puppeteer.errors</code>.</p> |
|
||||
| [EVALUATION_SCRIPT_URL](./puppeteer.evaluation_script_url.md) | |
|
||||
| [executablePath](./puppeteer.executablepath.md) | |
|
||||
| [launch](./puppeteer.launch.md) | |
|
||||
| [networkConditions](./puppeteer.networkconditions.md) | A list of network conditions to be used with <code>page.emulateNetworkConditions(networkConditions)</code>. Actual list of predefined conditions can be found in [src/common/NetworkConditions.ts](https://github.com/puppeteer/puppeteer/blob/main/src/common/NetworkConditions.ts). |
|
||||
| Variable | Description |
|
||||
| --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [connect](./puppeteer.connect.md) | |
|
||||
| [createBrowserFetcher](./puppeteer.createbrowserfetcher.md) | |
|
||||
| [DEFAULT_INTERCEPT_RESOLUTION_PRIORITY](./puppeteer.default_intercept_resolution_priority.md) | The default cooperative request interception resolution priority |
|
||||
| [defaultArgs](./puppeteer.defaultargs.md) | |
|
||||
| [devices](./puppeteer.devices.md) | A list of devices to be used with <code>page.emulate(options)</code>. Actual list of devices can be found in [src/common/DeviceDescriptors.ts](https://github.com/puppeteer/puppeteer/blob/main/src/common/DeviceDescriptors.ts). |
|
||||
| [errors](./puppeteer.errors.md) | |
|
||||
| [EVALUATION_SCRIPT_URL](./puppeteer.evaluation_script_url.md) | |
|
||||
| [executablePath](./puppeteer.executablepath.md) | |
|
||||
| [launch](./puppeteer.launch.md) | |
|
||||
| [networkConditions](./puppeteer.networkconditions.md) | A list of network conditions to be used with <code>page.emulateNetworkConditions(networkConditions)</code>. Actual list of predefined conditions can be found in [src/common/NetworkConditions.ts](https://github.com/puppeteer/puppeteer/blob/main/src/common/NetworkConditions.ts). |
|
||||
|
||||
## Type Aliases
|
||||
|
||||
|
@ -1,21 +0,0 @@
|
||||
---
|
||||
sidebar_label: CustomError.(constructor)
|
||||
---
|
||||
|
||||
# CustomError.(constructor)
|
||||
|
||||
Constructs a new instance of the `CustomError` class
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class CustomError {
|
||||
constructor(message?: string);
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ------ | ----------------- |
|
||||
| message | string | <i>(Optional)</i> |
|
@ -4,6 +4,10 @@ sidebar_label: CustomError
|
||||
|
||||
# CustomError class
|
||||
|
||||
> Warning: This API is now obsolete.
|
||||
>
|
||||
> Do not use.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
@ -12,8 +16,6 @@ export declare class CustomError extends Error
|
||||
|
||||
**Extends:** Error
|
||||
|
||||
## Constructors
|
||||
## Remarks
|
||||
|
||||
| Constructor | Modifiers | Description |
|
||||
| ------------------------------------------------------------------ | --------- | --------------------------------------------------------------- |
|
||||
| [(constructor)(message)](./puppeteer.customerror._constructor_.md) | | Constructs a new instance of the <code>CustomError</code> class |
|
||||
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `CustomError` class.
|
||||
|
@ -4,9 +4,13 @@ sidebar_label: errors
|
||||
|
||||
# errors variable
|
||||
|
||||
Puppeteer methods might throw errors if they are unable to fulfill a request. For example, `page.waitForSelector(selector[, options])` might fail if the selector doesn't match any nodes during the given timeframe.
|
||||
|
||||
For certain types of errors Puppeteer uses specific error classes. These classes are available via `puppeteer.errors`.
|
||||
> Warning: This API is now obsolete.
|
||||
>
|
||||
> Import error classes directly.
|
||||
>
|
||||
> Puppeteer methods might throw errors if they are unable to fulfill a request. For example, `page.waitForSelector(selector[, options])` might fail if the selector doesn't match any nodes during the given timeframe.
|
||||
>
|
||||
> For certain types of errors Puppeteer uses specific error classes. These classes are available via `puppeteer.errors`.
|
||||
|
||||
**Signature:**
|
||||
|
||||
@ -22,7 +26,7 @@ An example of handling a timeout error:
|
||||
try {
|
||||
await page.waitForSelector('.foo');
|
||||
} catch (e) {
|
||||
if (e instanceof puppeteer.errors.TimeoutError) {
|
||||
if (e instanceof TimeoutError) {
|
||||
// Do something if this is a timeout.
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,6 @@ sidebar_label: ProtocolError.code
|
||||
|
||||
```typescript
|
||||
class ProtocolError {
|
||||
code?: number;
|
||||
set code(code: number | undefined);
|
||||
}
|
||||
```
|
||||
|
@ -16,7 +16,7 @@ export declare class ProtocolError extends CustomError
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Modifiers | Type | Description |
|
||||
| --------------------------------------------------------------- | --------- | ------ | ----------------- |
|
||||
| [code?](./puppeteer.protocolerror.code.md) | | number | <i>(Optional)</i> |
|
||||
| [originalMessage](./puppeteer.protocolerror.originalmessage.md) | | string | |
|
||||
| Property | Modifiers | Type | Description |
|
||||
| --------------------------------------------------------------- | --------- | ------------------- | ----------- |
|
||||
| [code](./puppeteer.protocolerror.code.md) | | number \| undefined | |
|
||||
| [originalMessage](./puppeteer.protocolerror.originalmessage.md) | | string | |
|
||||
|
@ -8,6 +8,6 @@ sidebar_label: ProtocolError.originalMessage
|
||||
|
||||
```typescript
|
||||
class ProtocolError {
|
||||
originalMessage: string;
|
||||
set originalMessage(originalMessage: string);
|
||||
}
|
||||
```
|
||||
|
@ -1,23 +0,0 @@
|
||||
---
|
||||
sidebar_label: Puppeteer.errors
|
||||
---
|
||||
|
||||
# Puppeteer.errors property
|
||||
|
||||
> Warning: This API is now obsolete.
|
||||
>
|
||||
> Import directly puppeteer.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class Puppeteer {
|
||||
get errors(): typeof errors;
|
||||
}
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {errors} from 'puppeteer';
|
||||
```
|
@ -23,7 +23,6 @@ The constructor for this class is marked as internal. Third-party code should no
|
||||
| Property | Modifiers | Type | Description |
|
||||
| --------------------------------------------------------------- | --------------------- | ------------------------------------------------------------ | ----------- |
|
||||
| [devices](./puppeteer.puppeteer.devices.md) | <code>readonly</code> | typeof [devices](./puppeteer.devices.md) | |
|
||||
| [errors](./puppeteer.puppeteer.errors.md) | <code>readonly</code> | typeof [errors](./puppeteer.errors.md) | |
|
||||
| [networkConditions](./puppeteer.puppeteer.networkconditions.md) | <code>readonly</code> | typeof [networkConditions](./puppeteer.networkconditions.md) | |
|
||||
|
||||
## Methods
|
||||
|
@ -4,6 +4,10 @@ sidebar_label: PuppeteerErrors
|
||||
|
||||
# PuppeteerErrors interface
|
||||
|
||||
> Warning: This API is now obsolete.
|
||||
>
|
||||
> Do not use.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
|
@ -15,9 +15,14 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @deprecated Do not use.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export class CustomError extends Error {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor(message?: string) {
|
||||
super(message);
|
||||
this.name = this.constructor.name;
|
||||
@ -43,11 +48,39 @@ export class TimeoutError extends CustomError {}
|
||||
* @public
|
||||
*/
|
||||
export class ProtocolError extends CustomError {
|
||||
public code?: number;
|
||||
public originalMessage = '';
|
||||
#code?: number;
|
||||
#originalMessage = '';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
set code(code: number | undefined) {
|
||||
this.#code = code;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
get code(): number | undefined {
|
||||
return this.#code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
set originalMessage(originalMessage: string) {
|
||||
this.#originalMessage = originalMessage;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
get originalMessage(): string {
|
||||
return this.#originalMessage;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Do not use.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface PuppeteerErrors {
|
||||
@ -56,6 +89,8 @@ export interface PuppeteerErrors {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Import error classes directly.
|
||||
*
|
||||
* Puppeteer methods might throw errors if they are unable to fulfill a request.
|
||||
* For example, `page.waitForSelector(selector[, options])` might fail if the
|
||||
* selector doesn't match any nodes during the given timeframe.
|
||||
@ -70,7 +105,7 @@ export interface PuppeteerErrors {
|
||||
* try {
|
||||
* await page.waitForSelector('.foo');
|
||||
* } catch (e) {
|
||||
* if (e instanceof puppeteer.errors.TimeoutError) {
|
||||
* if (e instanceof TimeoutError) {
|
||||
* // Do something if this is a timeout.
|
||||
* }
|
||||
* }
|
||||
|
@ -20,7 +20,6 @@ import {
|
||||
} from './BrowserConnector.js';
|
||||
import {ConnectionTransport} from './ConnectionTransport.js';
|
||||
import {devices} from './DeviceDescriptors.js';
|
||||
import {errors} from './Errors.js';
|
||||
import {networkConditions} from './NetworkConditions.js';
|
||||
import {
|
||||
clearCustomQueryHandlers,
|
||||
@ -99,18 +98,6 @@ export class Puppeteer {
|
||||
return devices;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Import directly puppeteer.
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* import {errors} from 'puppeteer';
|
||||
* ```
|
||||
*/
|
||||
get errors(): typeof errors {
|
||||
return errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Import directly puppeteer.
|
||||
* @example
|
||||
|
@ -24,6 +24,7 @@ import {
|
||||
import {ElementHandle} from 'puppeteer-core/internal/common/ElementHandle.js';
|
||||
import utils from './utils.js';
|
||||
import assert from 'assert';
|
||||
import {TimeoutError} from 'puppeteer';
|
||||
|
||||
describe('AriaQueryHandler', () => {
|
||||
setupTestBrowserHooks();
|
||||
@ -516,7 +517,7 @@ describe('AriaQueryHandler', () => {
|
||||
});
|
||||
|
||||
it('should respect timeout', async () => {
|
||||
const {page, puppeteer} = getTestState();
|
||||
const {page} = getTestState();
|
||||
|
||||
const error = await page
|
||||
.waitForSelector('aria/[role="button"]', {
|
||||
@ -528,7 +529,7 @@ describe('AriaQueryHandler', () => {
|
||||
expect(error.message).toContain(
|
||||
'Waiting for selector `[role="button"]` failed: Waiting failed: 10ms exceeded'
|
||||
);
|
||||
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
|
||||
expect(error).toBeInstanceOf(TimeoutError);
|
||||
});
|
||||
|
||||
it('should have an error message specifically for awaiting an element to be hidden', async () => {
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
import expect from 'expect';
|
||||
import {TimeoutError} from 'puppeteer';
|
||||
import {getTestState, setupTestBrowserHooks} from './mocha-utils.js';
|
||||
import {waitEvent} from './utils.js';
|
||||
|
||||
@ -96,7 +97,7 @@ describe('BrowserContext', function () {
|
||||
await context.close();
|
||||
});
|
||||
it('should wait for a target', async () => {
|
||||
const {browser, puppeteer, server} = getTestState();
|
||||
const {browser, server} = getTestState();
|
||||
|
||||
const context = await browser.createIncognitoBrowserContext();
|
||||
let resolved = false;
|
||||
@ -110,7 +111,7 @@ describe('BrowserContext', function () {
|
||||
})
|
||||
.catch(error => {
|
||||
resolved = true;
|
||||
if (error instanceof puppeteer.errors.TimeoutError) {
|
||||
if (error instanceof TimeoutError) {
|
||||
console.error(error);
|
||||
} else {
|
||||
throw error;
|
||||
@ -123,7 +124,7 @@ describe('BrowserContext', function () {
|
||||
const target = await targetPromise;
|
||||
expect(await target.page()).toBe(page);
|
||||
} catch (error) {
|
||||
if (error instanceof puppeteer.errors.TimeoutError) {
|
||||
if (error instanceof TimeoutError) {
|
||||
console.error(error);
|
||||
} else {
|
||||
throw error;
|
||||
@ -133,7 +134,7 @@ describe('BrowserContext', function () {
|
||||
});
|
||||
|
||||
it('should timeout waiting for a non-existent target', async () => {
|
||||
const {browser, puppeteer, server} = getTestState();
|
||||
const {browser, server} = getTestState();
|
||||
|
||||
const context = await browser.createIncognitoBrowserContext();
|
||||
const error = await context
|
||||
@ -148,7 +149,7 @@ describe('BrowserContext', function () {
|
||||
.catch(error_ => {
|
||||
return error_;
|
||||
});
|
||||
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
|
||||
expect(error).toBeInstanceOf(TimeoutError);
|
||||
await context.close();
|
||||
});
|
||||
|
||||
|
@ -21,6 +21,7 @@ import {
|
||||
setupTestBrowserHooks,
|
||||
setupTestPageAndContextHooks,
|
||||
} from './mocha-utils.js';
|
||||
import {TimeoutError} from 'puppeteer';
|
||||
|
||||
const FILE_TO_UPLOAD = path.join(__dirname, '/../assets/file-to-upload.txt');
|
||||
|
||||
@ -100,33 +101,33 @@ describe('input tests', function () {
|
||||
expect(chooser).toBeTruthy();
|
||||
});
|
||||
it('should respect timeout', async () => {
|
||||
const {page, puppeteer} = getTestState();
|
||||
const {page} = getTestState();
|
||||
|
||||
let error!: Error;
|
||||
await page.waitForFileChooser({timeout: 1}).catch(error_ => {
|
||||
return (error = error_);
|
||||
});
|
||||
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
|
||||
expect(error).toBeInstanceOf(TimeoutError);
|
||||
});
|
||||
it('should respect default timeout when there is no custom timeout', async () => {
|
||||
const {page, puppeteer} = getTestState();
|
||||
const {page} = getTestState();
|
||||
|
||||
page.setDefaultTimeout(1);
|
||||
let error!: Error;
|
||||
await page.waitForFileChooser().catch(error_ => {
|
||||
return (error = error_);
|
||||
});
|
||||
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
|
||||
expect(error).toBeInstanceOf(TimeoutError);
|
||||
});
|
||||
it('should prioritize exact timeout over default timeout', async () => {
|
||||
const {page, puppeteer} = getTestState();
|
||||
const {page} = getTestState();
|
||||
|
||||
page.setDefaultTimeout(0);
|
||||
let error!: Error;
|
||||
await page.waitForFileChooser({timeout: 1}).catch(error_ => {
|
||||
return (error = error_);
|
||||
});
|
||||
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
|
||||
expect(error).toBeInstanceOf(TimeoutError);
|
||||
});
|
||||
it('should work with no timeout', async () => {
|
||||
const {page} = getTestState();
|
||||
|
@ -26,6 +26,7 @@ import {Page} from 'puppeteer-core/internal/api/Page.js';
|
||||
import {Product} from 'puppeteer-core/internal/common/Product.js';
|
||||
import {getTestState, itOnlyRegularInstall} from './mocha-utils.js';
|
||||
import utils from './utils.js';
|
||||
import {TimeoutError} from 'puppeteer';
|
||||
|
||||
const mkdtempAsync = promisify(fs.mkdtemp);
|
||||
const readFileAsync = promisify(fs.readFile);
|
||||
@ -529,7 +530,7 @@ describe('Launcher specs', function () {
|
||||
await puppeteer.launch(options).catch(error_ => {
|
||||
return (error = error_);
|
||||
});
|
||||
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
|
||||
expect(error).toBeInstanceOf(TimeoutError);
|
||||
});
|
||||
it('should work with timeout = 0', async () => {
|
||||
const {puppeteer, defaultBrowserOptions} = getTestState();
|
||||
|
@ -24,6 +24,7 @@ import {
|
||||
import os from 'os';
|
||||
import {ServerResponse} from 'http';
|
||||
import {HTTPRequest} from 'puppeteer-core/internal/common/HTTPRequest.js';
|
||||
import {TimeoutError} from 'puppeteer';
|
||||
|
||||
describe('navigation', function () {
|
||||
setupTestBrowserHooks();
|
||||
@ -228,7 +229,7 @@ describe('navigation', function () {
|
||||
}
|
||||
});
|
||||
it('should fail when exceeding maximum navigation timeout', async () => {
|
||||
const {page, server, puppeteer} = getTestState();
|
||||
const {page, server} = getTestState();
|
||||
|
||||
// Hang for request to the empty.html
|
||||
server.setRoute('/empty.html', () => {});
|
||||
@ -239,10 +240,10 @@ describe('navigation', function () {
|
||||
return (error = error_);
|
||||
});
|
||||
expect(error.message).toContain('Navigation timeout of 1 ms exceeded');
|
||||
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
|
||||
expect(error).toBeInstanceOf(TimeoutError);
|
||||
});
|
||||
it('should fail when exceeding default maximum navigation timeout', async () => {
|
||||
const {page, server, puppeteer} = getTestState();
|
||||
const {page, server} = getTestState();
|
||||
|
||||
// Hang for request to the empty.html
|
||||
server.setRoute('/empty.html', () => {});
|
||||
@ -252,10 +253,10 @@ describe('navigation', function () {
|
||||
return (error = error_);
|
||||
});
|
||||
expect(error.message).toContain('Navigation timeout of 1 ms exceeded');
|
||||
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
|
||||
expect(error).toBeInstanceOf(TimeoutError);
|
||||
});
|
||||
it('should fail when exceeding default maximum timeout', async () => {
|
||||
const {page, server, puppeteer} = getTestState();
|
||||
const {page, server} = getTestState();
|
||||
|
||||
// Hang for request to the empty.html
|
||||
server.setRoute('/empty.html', () => {});
|
||||
@ -265,10 +266,10 @@ describe('navigation', function () {
|
||||
return (error = error_);
|
||||
});
|
||||
expect(error.message).toContain('Navigation timeout of 1 ms exceeded');
|
||||
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
|
||||
expect(error).toBeInstanceOf(TimeoutError);
|
||||
});
|
||||
it('should prioritize default navigation timeout over default timeout', async () => {
|
||||
const {page, server, puppeteer} = getTestState();
|
||||
const {page, server} = getTestState();
|
||||
|
||||
// Hang for request to the empty.html
|
||||
server.setRoute('/empty.html', () => {});
|
||||
@ -279,7 +280,7 @@ describe('navigation', function () {
|
||||
return (error = error_);
|
||||
});
|
||||
expect(error.message).toContain('Navigation timeout of 1 ms exceeded');
|
||||
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
|
||||
expect(error).toBeInstanceOf(TimeoutError);
|
||||
});
|
||||
it('should disable timeout when its set to 0', async () => {
|
||||
const {page, server} = getTestState();
|
||||
|
@ -28,6 +28,7 @@ import {
|
||||
} from './mocha-utils.js';
|
||||
import utils, {attachFrame, waitEvent} from './utils.js';
|
||||
import {CDPPage} from 'puppeteer-core/internal/common/Page.js';
|
||||
import {TimeoutError} from 'puppeteer';
|
||||
|
||||
describe('Page', function () {
|
||||
setupTestBrowserHooks();
|
||||
@ -924,7 +925,7 @@ describe('Page', function () {
|
||||
expect(request.url()).toBe(server.PREFIX + '/digits/2.png');
|
||||
});
|
||||
it('should respect timeout', async () => {
|
||||
const {page, puppeteer} = getTestState();
|
||||
const {page} = getTestState();
|
||||
|
||||
let error!: Error;
|
||||
await page
|
||||
@ -937,10 +938,10 @@ describe('Page', function () {
|
||||
.catch(error_ => {
|
||||
return (error = error_);
|
||||
});
|
||||
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
|
||||
expect(error).toBeInstanceOf(TimeoutError);
|
||||
});
|
||||
it('should respect default timeout', async () => {
|
||||
const {page, puppeteer} = getTestState();
|
||||
const {page} = getTestState();
|
||||
|
||||
let error!: Error;
|
||||
page.setDefaultTimeout(1);
|
||||
@ -951,7 +952,7 @@ describe('Page', function () {
|
||||
.catch(error_ => {
|
||||
return (error = error_);
|
||||
});
|
||||
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
|
||||
expect(error).toBeInstanceOf(TimeoutError);
|
||||
});
|
||||
it('should work with no timeout', async () => {
|
||||
const {page, server} = getTestState();
|
||||
@ -987,7 +988,7 @@ describe('Page', function () {
|
||||
expect(response.url()).toBe(server.PREFIX + '/digits/2.png');
|
||||
});
|
||||
it('should respect timeout', async () => {
|
||||
const {page, puppeteer} = getTestState();
|
||||
const {page} = getTestState();
|
||||
|
||||
let error!: Error;
|
||||
await page
|
||||
@ -1000,10 +1001,10 @@ describe('Page', function () {
|
||||
.catch(error_ => {
|
||||
return (error = error_);
|
||||
});
|
||||
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
|
||||
expect(error).toBeInstanceOf(TimeoutError);
|
||||
});
|
||||
it('should respect default timeout', async () => {
|
||||
const {page, puppeteer} = getTestState();
|
||||
const {page} = getTestState();
|
||||
|
||||
let error!: Error;
|
||||
page.setDefaultTimeout(1);
|
||||
@ -1014,7 +1015,7 @@ describe('Page', function () {
|
||||
.catch(error_ => {
|
||||
return (error = error_);
|
||||
});
|
||||
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
|
||||
expect(error).toBeInstanceOf(TimeoutError);
|
||||
});
|
||||
it('should work with predicate', async () => {
|
||||
const {page, server} = getTestState();
|
||||
@ -1101,12 +1102,12 @@ describe('Page', function () {
|
||||
expect(t1 - t2).toBeGreaterThanOrEqual(400);
|
||||
});
|
||||
it('should respect timeout', async () => {
|
||||
const {page, puppeteer} = getTestState();
|
||||
const {page} = getTestState();
|
||||
let error!: Error;
|
||||
await page.waitForNetworkIdle({timeout: 1}).catch(error_ => {
|
||||
return (error = error_);
|
||||
});
|
||||
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
|
||||
expect(error).toBeInstanceOf(TimeoutError);
|
||||
});
|
||||
it('should respect idleTime', async () => {
|
||||
const {page, server} = getTestState();
|
||||
@ -1440,7 +1441,7 @@ describe('Page', function () {
|
||||
expect(result).toBe(`${doctype}${expectedOutput}`);
|
||||
});
|
||||
it('should respect timeout', async () => {
|
||||
const {page, server, puppeteer} = getTestState();
|
||||
const {page, server} = getTestState();
|
||||
|
||||
const imgPath = '/img.png';
|
||||
// stall for image
|
||||
@ -1453,10 +1454,10 @@ describe('Page', function () {
|
||||
.catch(error_ => {
|
||||
return (error = error_);
|
||||
});
|
||||
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
|
||||
expect(error).toBeInstanceOf(TimeoutError);
|
||||
});
|
||||
it('should respect default navigation timeout', async () => {
|
||||
const {page, server, puppeteer} = getTestState();
|
||||
const {page, server} = getTestState();
|
||||
|
||||
page.setDefaultNavigationTimeout(1);
|
||||
const imgPath = '/img.png';
|
||||
@ -1468,7 +1469,7 @@ describe('Page', function () {
|
||||
.catch(error_ => {
|
||||
return (error = error_);
|
||||
});
|
||||
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
|
||||
expect(error).toBeInstanceOf(TimeoutError);
|
||||
});
|
||||
it('should await resources to load', async () => {
|
||||
const {page, server} = getTestState();
|
||||
@ -2053,7 +2054,7 @@ describe('Page', function () {
|
||||
});
|
||||
|
||||
it('should respect timeout', async () => {
|
||||
const {isHeadless, page, server, puppeteer} = getTestState();
|
||||
const {isHeadless, page, server} = getTestState();
|
||||
if (!isHeadless) {
|
||||
return;
|
||||
}
|
||||
@ -2064,7 +2065,7 @@ describe('Page', function () {
|
||||
await page.pdf({timeout: 1}).catch(_error => {
|
||||
return (error = _error);
|
||||
});
|
||||
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
|
||||
expect(error).toBeInstanceOf(TimeoutError);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
import expect from 'expect';
|
||||
import {ServerResponse} from 'http';
|
||||
import {TimeoutError} from 'puppeteer';
|
||||
import {Page} from 'puppeteer-core/internal/api/Page.js';
|
||||
import {Target} from 'puppeteer-core/internal/common/Target.js';
|
||||
import {
|
||||
@ -310,7 +311,7 @@ describe('Target', function () {
|
||||
|
||||
describe('Browser.waitForTarget', () => {
|
||||
it('should wait for a target', async () => {
|
||||
const {browser, puppeteer, server} = getTestState();
|
||||
const {browser, server} = getTestState();
|
||||
|
||||
let resolved = false;
|
||||
const targetPromise = browser.waitForTarget(target => {
|
||||
@ -322,7 +323,7 @@ describe('Target', function () {
|
||||
})
|
||||
.catch(error => {
|
||||
resolved = true;
|
||||
if (error instanceof puppeteer.errors.TimeoutError) {
|
||||
if (error instanceof TimeoutError) {
|
||||
console.error(error);
|
||||
} else {
|
||||
throw error;
|
||||
@ -335,7 +336,7 @@ describe('Target', function () {
|
||||
const target = await targetPromise;
|
||||
expect(await target.page()).toBe(page);
|
||||
} catch (error) {
|
||||
if (error instanceof puppeteer.errors.TimeoutError) {
|
||||
if (error instanceof TimeoutError) {
|
||||
console.error(error);
|
||||
} else {
|
||||
throw error;
|
||||
@ -344,7 +345,7 @@ describe('Target', function () {
|
||||
await page.close();
|
||||
});
|
||||
it('should timeout waiting for a non-existent target', async () => {
|
||||
const {browser, server, puppeteer} = getTestState();
|
||||
const {browser, server} = getTestState();
|
||||
|
||||
let error!: Error;
|
||||
await browser
|
||||
@ -359,7 +360,7 @@ describe('Target', function () {
|
||||
.catch(error_ => {
|
||||
return (error = error_);
|
||||
});
|
||||
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
|
||||
expect(error).toBeInstanceOf(TimeoutError);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
import expect from 'expect';
|
||||
import {TimeoutError} from 'puppeteer';
|
||||
import {isErrorLike} from 'puppeteer-core/internal/util/ErrorLike.js';
|
||||
import {
|
||||
createTimeout,
|
||||
@ -240,7 +241,7 @@ describe('waittask specs', function () {
|
||||
await waitForFunction;
|
||||
});
|
||||
it('should respect timeout', async () => {
|
||||
const {page, puppeteer} = getTestState();
|
||||
const {page} = getTestState();
|
||||
|
||||
let error!: Error;
|
||||
await page
|
||||
@ -254,11 +255,11 @@ describe('waittask specs', function () {
|
||||
return (error = error_);
|
||||
});
|
||||
|
||||
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
|
||||
expect(error).toBeInstanceOf(TimeoutError);
|
||||
expect(error?.message).toContain('Waiting failed: 10ms exceeded');
|
||||
});
|
||||
it('should respect default timeout', async () => {
|
||||
const {page, puppeteer} = getTestState();
|
||||
const {page} = getTestState();
|
||||
|
||||
page.setDefaultTimeout(1);
|
||||
let error!: Error;
|
||||
@ -269,7 +270,7 @@ describe('waittask specs', function () {
|
||||
.catch(error_ => {
|
||||
return (error = error_);
|
||||
});
|
||||
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
|
||||
expect(error).toBeInstanceOf(TimeoutError);
|
||||
expect(error?.message).toContain('Waiting failed: 1ms exceeded');
|
||||
});
|
||||
it('should disable timeout when its set to 0', async () => {
|
||||
@ -669,13 +670,13 @@ describe('waittask specs', function () {
|
||||
expect(handle).toBe(null);
|
||||
});
|
||||
it('should respect timeout', async () => {
|
||||
const {page, puppeteer} = getTestState();
|
||||
const {page} = getTestState();
|
||||
|
||||
let error!: Error;
|
||||
await page.waitForSelector('div', {timeout: 10}).catch(error_ => {
|
||||
return (error = error_);
|
||||
});
|
||||
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
|
||||
expect(error).toBeInstanceOf(TimeoutError);
|
||||
expect(error?.message).toContain(
|
||||
'Waiting for selector `div` failed: Waiting failed: 10ms exceeded'
|
||||
);
|
||||
@ -755,13 +756,13 @@ describe('waittask specs', function () {
|
||||
).toBe('hello world ');
|
||||
});
|
||||
it('should respect timeout', async () => {
|
||||
const {page, puppeteer} = getTestState();
|
||||
const {page} = getTestState();
|
||||
|
||||
let error!: Error;
|
||||
await page.waitForXPath('//div', {timeout: 10}).catch(error_ => {
|
||||
return (error = error_);
|
||||
});
|
||||
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
|
||||
expect(error).toBeInstanceOf(TimeoutError);
|
||||
expect(error?.message).toContain('Waiting failed: 10ms exceeded');
|
||||
});
|
||||
it('should run in specified frame', async () => {
|
||||
|
Loading…
Reference in New Issue
Block a user