docs: Improved JSDoc for expect.toPass (#29722)

This commit is contained in:
Renan Greca 2024-03-01 19:51:23 +01:00 committed by GitHub
parent a8c26d235c
commit 4e0bd6286e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 36 additions and 2 deletions

View File

@ -6957,7 +6957,24 @@ interface GenericAssertions<R> {
type FunctionAssertions = {
/**
* Retries the callback until it passes.
* Retries the callback until all assertions within it pass or the `timeout` value is reached.
* The `intervals` parameter can be used to establish the probing frequency or pattern.
*
* **Usage**
* ```js
* await expect(async () => {
* const response = await page.request.get('https://api.example.com');
* expect(response.status()).toBe(200);
* }).toPass({
* // Probe, wait 1s, probe, wait 2s, probe, wait 10s, probe, wait 10s, probe
* intervals: [1_000, 2_000, 10_000], // Defaults to [100, 250, 500, 1000].
* timeout: 60_000 // Defaults to 0
* });
* ```
*
* Note that by default `toPass` does not respect custom expect timeout.
*
* @param options
*/
toPass(options?: { timeout?: number, intervals?: number[] }): Promise<void>;
};

View File

@ -341,7 +341,24 @@ interface GenericAssertions<R> {
type FunctionAssertions = {
/**
* Retries the callback until it passes.
* Retries the callback until all assertions within it pass or the `timeout` value is reached.
* The `intervals` parameter can be used to establish the probing frequency or pattern.
*
* **Usage**
* ```js
* await expect(async () => {
* const response = await page.request.get('https://api.example.com');
* expect(response.status()).toBe(200);
* }).toPass({
* // Probe, wait 1s, probe, wait 2s, probe, wait 10s, probe, wait 10s, probe
* intervals: [1_000, 2_000, 10_000], // Defaults to [100, 250, 500, 1000].
* timeout: 60_000 // Defaults to 0
* });
* ```
*
* Note that by default `toPass` does not respect custom expect timeout.
*
* @param options
*/
toPass(options?: { timeout?: number, intervals?: number[] }): Promise<void>;
};