feat: Support intervals arg for toPass
This commit is contained in:
parent
7ad0a12c23
commit
688bccf1f7
|
|
@ -29,7 +29,7 @@ await page.getByRole('link', { name: 'Collection of blue and white' }).click();
|
||||||
await expect(page.getByRole('heading', { name: 'Light and easy' })).toBeVisible();
|
await expect(page.getByRole('heading', { name: 'Light and easy' })).toBeVisible();
|
||||||
```
|
```
|
||||||
|
|
||||||
- `expect(callback).toPass()` timeout can now be configured by `expect.toPass.timeout` option [globally](./api/class-testconfig#test-config-expect) or in [project config](./api/class-testproject#test-project-expect)
|
- `expect(callback).toPass()` timeout and intervals can now be configured by `expect.toPass.timeout` and `expect.toPass.intervals` options [globally](./api/class-testconfig#test-config-expect) or in [project config](./api/class-testproject#test-project-expect)
|
||||||
|
|
||||||
- [`event: ElectronApplication.console`] event is emitted when Electron main process calls console API methods.
|
- [`event: ElectronApplication.console`] event is emitted when Electron main process calls console API methods.
|
||||||
```js
|
```js
|
||||||
|
|
|
||||||
|
|
@ -369,6 +369,7 @@ export async function toPass(
|
||||||
) {
|
) {
|
||||||
const testInfo = currentTestInfo();
|
const testInfo = currentTestInfo();
|
||||||
const timeout = takeFirst(options.timeout, testInfo?._projectInternal.expect?.toPass?.timeout, 0);
|
const timeout = takeFirst(options.timeout, testInfo?._projectInternal.expect?.toPass?.timeout, 0);
|
||||||
|
const intervals = takeFirst(options.intervals, testInfo?._projectInternal.expect?.toPass?.intervals, [100, 250, 500, 1000]);
|
||||||
|
|
||||||
const { deadline, timeoutMessage } = testInfo ? testInfo._deadlineForMatcher(timeout) : TestInfoImpl._defaultDeadlineForMatcher(timeout);
|
const { deadline, timeoutMessage } = testInfo ? testInfo._deadlineForMatcher(timeout) : TestInfoImpl._defaultDeadlineForMatcher(timeout);
|
||||||
const result = await pollAgainstDeadline<Error|undefined>(async () => {
|
const result = await pollAgainstDeadline<Error|undefined>(async () => {
|
||||||
|
|
@ -380,7 +381,7 @@ export async function toPass(
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return { continuePolling: !this.isNot, result: e };
|
return { continuePolling: !this.isNot, result: e };
|
||||||
}
|
}
|
||||||
}, deadline, options.intervals || [100, 250, 500, 1000]);
|
}, deadline, intervals);
|
||||||
|
|
||||||
if (result.timedOut) {
|
if (result.timedOut) {
|
||||||
const message = result.result ? [
|
const message = result.result ? [
|
||||||
|
|
|
||||||
10
packages/playwright/types/test.d.ts
vendored
10
packages/playwright/types/test.d.ts
vendored
|
|
@ -702,6 +702,11 @@ interface TestConfig {
|
||||||
* timeout for toPass method in milliseconds.
|
* timeout for toPass method in milliseconds.
|
||||||
*/
|
*/
|
||||||
timeout?: number;
|
timeout?: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* intervals for toPass method in milliseconds.
|
||||||
|
*/
|
||||||
|
intervals?: number[];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -8596,6 +8601,11 @@ interface TestProject {
|
||||||
* timeout for toPass method in milliseconds.
|
* timeout for toPass method in milliseconds.
|
||||||
*/
|
*/
|
||||||
timeout?: number;
|
timeout?: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* interval for toPass method in milliseconds.
|
||||||
|
*/
|
||||||
|
intervals?: number[];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue