Commit Graph

14 Commits

Author SHA1 Message Date
Dmitry Gozman
1e1df6395f
chore: generate expect types (#13439) 2022-04-11 10:42:19 -07:00
Dmitry Gozman
4bb563b015
fix(expect): proper return types (#13334)
A few changes:
- `Matchers<R, T>` now carries both return and argument type.
- Based on the argument type, we apply playwright-specific Page/Locator matchers.
- Return type is usually void, unless wrapped with `expect.resolves`,
  `expect.rejects` or `expect.poll()`.
- To preserve compatibility with any extended types in the wild,
  argument type is optional.
2022-04-05 16:11:11 -07:00
Ross Wollman
12abae7f31
feat(test-runner): friendly expect errors for typos (#13229)
If you typo'd an `expect` property, you got a cryptic error message:

```
Uncaught TypeError: Cannot create proxy with a non-object as target or handler
```

Now we get this nice friendly message:

```
  1) a.spec.ts:6:9 › explodes ======================================================================

    Error: expect: Property 'toBeLessThen' not found.

    Did you mean 'toBeLessThan'?

    See https://playwright.dev/docs/test-assertions for available options and documentation.

      5 |         const { test } = pwt;
      6 |         test('explodes', () => {
    > 7 |           expect.soft(1).toBeLessThen();
        |           ^
      8 |         });
      9 |

```

Fixes #13218
2022-04-01 13:38:22 -07:00
Andrey Lushnikov
cfe92e1608
feat(test-runner): implement expect.poll (#12815)
This patch implements `expect.poll()` method that polls given
predicate until a given synchronous predicate completes.

Usage:

```js
// wait until page gets 3 frames.
await expect.poll(() => page.frames().length, {
  timeout: 1000,
  message: 'custom error message',
}).toBe(3);
```

Fixes #10235
2022-03-18 16:31:26 -07:00
Max Schmitt
e231db1810
chore: restore expect.any()/expect.anything() (#12820) 2022-03-16 21:34:41 +01:00
Andrey Lushnikov
2336692e8a
feat: support clarification message for expect (#11735)
The clarification message is displayed in the HTML report as the name of the step:

![image](https://user-images.githubusercontent.com/746130/151852652-48194140-5ea4-439d-afee-12583a8caf71.png)

It is also shown in terminal output:

![image](https://user-images.githubusercontent.com/746130/151852666-5c956ef1-6e94-4bc2-8e55-b58688dfc7e0.png)

Fixes #7816
2022-01-31 17:14:59 -08:00
Joel Einbinder
7a02c52144
feat(test-runner): specific playwright types for expect (#10670) 2021-12-13 13:42:36 -05:00
Max Schmitt
4a96a75fe8
test(test-runner): add test for hiding conditional expect matchers (#10703) 2021-12-03 14:55:16 -08:00
Max Schmitt
cd22072685
chore: enable object-curly-spacing in ESLint (#9168) 2021-09-27 18:58:08 +02:00
Joel Einbinder
0cf9cf0829
fix(test-runner): set expand: false for expect. (#7722) 2021-07-19 11:59:53 -05:00
Max Schmitt
a3a9ccad6f
fix(test-runner): do not require esModuleInterop=true (#7100) 2021-06-14 21:58:10 +02:00
Dmitry Gozman
8c13f679b7
fix(test runner): remove folio/jest namespaces in expect matchers (#6930) 2021-06-07 08:02:01 -07:00
Dmitry Gozman
46a0213769
chore: remove internal uses of "folio" (#6931)
Replaced by "pwt" or "playwright test".
2021-06-06 22:07:07 -07:00
Dmitry Gozman
f745bf1fbc
chore: bring in folio source (#6923)
- Source now lives at `src/test`.
- Former folio tests live at `tests/playwright-test`.
- We use `src/test/internal.ts` that exposes base test without
  Playwright fixtures for most tests (to avoid modifications for now).
- Test types live in `types/testFoo.d.ts`.
- Stable test runner is installed to `tests/config/test-runner` during `npm install`.
- All deps including test-only are now listed in `package.json`.
  Non-test deps must also be listed in `build_package.js` to get included.
2021-06-06 17:09:53 -07:00