Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: remove expect.configure({poll}) (#23060)

Pavel Feldman04070a59e1c5
diff --git a/docs/src/test-assertions-js.md b/docs/src/test-assertions-js.md
index c28fd9d653..085fdc1f25 100644
--- a/docs/src/test-assertions-js.md
+++ b/docs/src/test-assertions-js.md
@@ -121,10 +121,10 @@ The same works with soft assertions:
expect.soft(value, 'my soft assertion').toBe(56);
```
-## expect.configurte
+## expect.configure
You can create your own pre-configured `expect` instance to have its own
-defaults such as `timeout`, `soft` and `poll`.
+defaults such as `timeout` and `soft`.
```js
const slowExpect = expect.configure({ timeout: 10000 });
diff --git a/packages/playwright-test/src/matchers/expect.ts b/packages/playwright-test/src/matchers/expect.ts
index 4b4e143886..178d41e43b 100644
--- a/packages/playwright-test/src/matchers/expect.ts
+++ b/packages/playwright-test/src/matchers/expect.ts
@@ -136,14 +136,14 @@ function createExpect(info: ExpectMetaInfo) {
if (property === 'poll') {
return (actual: unknown, messageOrOptions?: ExpectMessage & { timeout?: number, intervals?: number[] }) => {
const poll = isString(messageOrOptions) ? {} : messageOrOptions || {};
- return configure({ poll })(actual, messageOrOptions) as any;
+ return configure({ _poll: poll })(actual, messageOrOptions) as any;
};
}
return expectLibrary[property];
},
});
- const configure = (configuration: { message?: string, timeout?: number, soft?: boolean, poll?: boolean | { timeout?: number, intervals?: number[] } }) => {
+ const configure = (configuration: { message?: string, timeout?: number, soft?: boolean, _poll?: boolean | { timeout?: number, intervals?: number[] } }) => {
const newInfo = { ...info };
if ('message' in configuration)
newInfo.message = configuration.message;
@@ -151,11 +151,11 @@ function createExpect(info: ExpectMetaInfo) {
newInfo.timeout = configuration.timeout;
if ('soft' in configuration)
newInfo.isSoft = configuration.soft;
- if ('poll' in configuration) {
- newInfo.isPoll = !!configuration.poll;
- if (typeof configuration.poll === 'object') {
- newInfo.pollTimeout = configuration.poll.timeout;
- newInfo.pollIntervals = configuration.poll.intervals;
+ if ('_poll' in configuration) {
+ newInfo.isPoll = !!configuration._poll;
+ if (typeof configuration._poll === 'object') {
+ newInfo.pollTimeout = configuration._poll.timeout;
+ newInfo.pollIntervals = configuration._poll.intervals;
}
}
return createExpect(newInfo);
diff --git a/tests/playwright-test/expect-configure.spec.ts b/tests/playwright-test/expect-configure.spec.ts
index 741155f6e3..a43fefaa7d 100644
--- a/tests/playwright-test/expect-configure.spec.ts
+++ b/tests/playwright-test/expect-configure.spec.ts
@@ -88,24 +88,6 @@ test('should configure soft', async ({ runInlineTest }) => {
expect(result.output).toContain('woof-woof');
});
-test('should configure poll', async ({ runInlineTest }) => {
- const result = await runInlineTest({
- 'a.spec.ts': `
- import { test, expect } from '@playwright/test';
- const pollingExpect = expect.configure({ poll: { timeout: 1000, intervals: [0, 10000] } });
- test('should fail', async () => {
- let probes = 0;
- const startTime = Date.now();
- await pollingExpect(() => ++probes).toBe(3).catch(() => {});
- // Probe at 0 and epsilon.
- expect(probes).toBe(2);
- expect(Date.now() - startTime).toBeLessThan(5000);
- });
- `
- });
- expect(result.exitCode).toBe(0);
-});
-
test('should chain configure', async ({ runInlineTest }) => {
const result = await runInlineTest({
'expect-test.spec.ts': `
@@ -143,11 +125,11 @@ test('should configure soft poll', async ({ runInlineTest }) => {
const result = await runInlineTest({
'a.spec.ts': `
import { test, expect } from '@playwright/test';
- const pollingExpect = expect.configure({ soft: true, poll: { timeout: 1000, intervals: [0, 10000] } });
+ const softExpect = expect.configure({ soft: true });
test('should fail', async () => {
let probes = 0;
const startTime = Date.now();
- await pollingExpect(() => ++probes).toBe(3);
+ await softExpect.poll(() => ++probes, { timeout: 1000, intervals: [0, 10000] }).toBe(3);
// Probe at 0 and epsilon.
expect(probes).toBe(2);
expect(Date.now() - startTime).toBeLessThan(5000);