Commit Graph

429 Commits

Author SHA1 Message Date
Pavel Feldman
40d5e3a3c9
chore: use utils via index export (3) (#13403) 2022-04-07 13:55:44 -07:00
Max Schmitt
5536e64538
feat(test-runner): support filtering by columns (#13401) 2022-04-07 22:45:45 +02:00
Dmitry Gozman
1dc2d02d35
chore: roll stable-test-runnner to apr-07 (#13374) 2022-04-07 14:58:04 +02:00
Pavel Feldman
bde7bf4ea9
chore: move registry & dispatchers to under server (#13370) 2022-04-06 22:21:27 -07:00
Pavel Feldman
5ae2017a5b
chore: always import type (#13365) 2022-04-06 14:57:14 -07:00
Ivan Kaliada
424de6c38f
fix: resolve ts compilerOptions.paths with prefixes and suffixes (#13105) 2022-04-06 14:14:03 -07:00
Pavel Feldman
f3bd910820
chore(test-runner): rewrite poll, soft, wrap (#13335) 2022-04-05 17:47:35 -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
Dmitry Gozman
e31a5b690a
chore: unrelease toHaveScreenshot and screenshotsDir (#13304) 2022-04-05 08:34:51 -07:00
Dmitry Gozman
a09b8dfa36
chore: unrelease 'fonts' screenshot option (#13300) 2022-04-04 14:51:11 -07:00
Ross Wollman
8a6b640fca
test: mark enum babel test as failing (#13282) 2022-04-04 12:49:39 -07:00
Ross Wollman
3636d8548f
chore: fix lint (#13279) 2022-04-03 21:22:47 -07:00
Ross Wollman
014deed913
test: repro enums in tsx undefined (#13272)
The enums imported from the .tsx file are ending up as "undefined";
from the .ts file they are defined.

Repro for #13265.
2022-04-03 21:12:00 -07:00
Pavel Feldman
66cf82766e
test(html-reporter): add image diff tests (#13262) 2022-04-01 18:11:15 -07:00
Pavel Feldman
55ee41c848
feat(html): render image diff slider (#13257) 2022-04-01 15:27:51 -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
Dmitry Gozman
fee9b6007f
test: fix windows paths in golden.spec (#13258) 2022-04-01 13:12:29 -07:00
Ross Wollman
16efbdef98
chore: remove/rename FullConfig._attachments (#13233)
This was originally introduced in #12734.

It will be replaced with GlobalInfo (#13083), but not before the 1.21
release.
2022-04-01 12:36:05 -07:00
Ross Wollman
e5ba0d6846
test: ensure tests do not run after globalSetup fail (#13255)
Resolves #13244
2022-04-01 12:35:25 -07:00
Dmitry Gozman
a200fe3528
feat(screenshot): rename "size" option to "scale" (#13254)
Drive-by: fix `caret` handling in `toHaveScreenshot`.
2022-04-01 12:28:40 -07:00
Pavel Feldman
6a463195c4
chore: allow multiple image diffs (#13202) 2022-03-31 14:11:34 -07:00
Pavel Feldman
0346b5204b
chore: roll test runner to next (#13220) 2022-03-31 14:11:11 -07:00
Pavel Feldman
923f74c5a6
chore: allow matchers decorate step title (#13199) 2022-03-30 21:52:00 -07:00
Pavel Feldman
42f260c688
chore: prepare image diff for refactornig (#13197) 2022-03-30 17:42:08 -07:00
Pavel Feldman
81e7c0a77c
chore(html-report): render metainfo as a chip (#13166) 2022-03-29 18:13:08 -07:00
Pavel Feldman
5e17ed137b
fix(html-report): only invoke git once (#13165) 2022-03-29 15:49:58 -07:00
Dmitry Gozman
eb09306db2
feat(connect): add connectOptions.timeout (#13163) 2022-03-29 15:03:43 -07:00
Andrey Lushnikov
aa1daeba85
fix(html): put HTML report next to package.json by default (#13141)
Fixes #12970
2022-03-29 14:19:31 -07:00
Dmitry Gozman
de0af27837
feat(test runner): show last tests in the worker on teardown error (#13139) 2022-03-28 19:58:24 -07:00
Dmitry Gozman
d59c2b996f
fix(parallel): minimize the number of beforeAll/afterAll hooks in parallel mode (#13138)
Previously, we always formed groups consisting of a single test.
Now, we group tests that share `beforeAll`/`afterAll` hooks into
`config.workers` equally-sized groups.
2022-03-28 16:10:32 -07:00
Dmitry Gozman
9420a53939
fix(esm): make sure import from './foo.js' is supported (#13137)
Drive-by: migrate all @esm tests to esm.spec.ts.
2022-03-28 14:37:46 -07:00
Pavel Feldman
a58707b8a6
chore: group tests under tests/ (2) (#13082) 2022-03-25 23:09:02 -07:00
Max Schmitt
1797c5c249
chore(test-runner): support self signed certificate in webServer (#13032) 2022-03-24 17:30:52 +01:00
Dmitry Gozman
3688e74e3e
fix(list mode): print errors to stderr (#13016)
`--list` mode now prints any errors encountered during test collection,
for example syntax errors, to `stderr`.
2022-03-24 07:33:33 -07:00
Andrey Lushnikov
e1700bd167
feat: use package.json directory as a default for outputDir (#12942)
This patch:
- starts using directory of `package.json` to resolve default
  output directory path
- starts using either `package.json` directory or configuration
  directory to resolve all relative paths

References #12970
2022-03-23 16:05:49 -07:00
Xiaoxing Ye
04e9d2ec08
test(test-runner): fix reporter-list test cannot be run on win32 vscode (#12951) 2022-03-23 11:48:05 +01:00
Ross Wollman
541fb39a51
feat(html-reporter): add report context header (#12734)
Resolves #11318.

* Adds `TestConfig.attachments` public API. (We opted to not implement an analog to the async `TestInfo.attach(…)` API.)
* Adds `TestConfig.attachments` to common reporters.
* Dogfoods some git and CI-info inference to generate useful atttachments
* Updates HTML Reporter to include a side bar to present a pre-defined set of attachments (a.k.a git/commit context sidebar)

Here's what it looks like:

<img width="1738" alt="Screen Shot 2022-03-21 at 3 23 28 PM" src="https://user-images.githubusercontent.com/11915034/159373291-8b937d30-fba3-472a-853a-766018f6b3e2.png">

See `tests/playwright-test/reporter-html.spec.ts` for an example of usage (for dogfood-ing only). In the future, if this becomes user-facing, there the Global Setup bit would likely become unnecessary (as would interaction with attachments array); there would likely just be a nice top-level config and/or CLI flag to enable collecting of info.
2022-03-22 16:28:04 -07:00
Max Schmitt
d8ab76bf64
chore: throw when a Promise was passed to toMatchSnapshot (#12906) 2022-03-22 16:36:09 +01:00
Andrey Lushnikov
7f51336068
fix: allow toMatchSnapshot to use text comparator for text data (#12934)
This was regressed awhile ago.

In v1.17 we shipped the following code: 30e15ad36f/packages/playwright-test/src/matchers/golden.ts (L122-L131)

`toMatchSnapshot` should fallback to text comparator in case of
unknown extension and string data.

Fixes #12862
2022-03-21 16:42:21 -07:00
Andrey Lushnikov
c18077c0de
feat(toHaveScreenshot): align screenshot generation & comparison (#12812)
This patch aligns the strategies that are used to generate new
screnshot expectations and to compare screenshot expectations against
baseline.

With this patch, `toHaveScreenshot` will:
- when generating a new expectation: will wait for 2 consecutive
  screenshots to match and accept the last one as expectation.
- when given an expectation:
  * will compare first screenshot against expectation. If matches,
    resolve successfully
  * if first screenshot doesn't match, then wait for 2 consecutive
    screenshots to match and then compare last screenshot with the
    expectation.

An example of a new detailed call log:

```
  1) a.spec.ts:3:1 › should work ===================================================================

    Error: Screenshot comparison failed:

      20000 pixels (ratio 0.03 of all image pixels) are different

    Call log:
      - expect.toHaveScreenshot with timeout 5000ms
      -   verifying given screenshot expectation
      - fast-path: checking first screenshot to match expectation
      - taking page screenshot
      -   disabled all CSS animations
      -   waiting for fonts to load...
      -   fonts in all frames are loaded
      - fast-path failed: first screenshot did not match expectation - 20000 pixels (ratio 0.03 of all image pixels) are different
      - waiting for 2 consecutive screenshots to match
      - waiting 100ms before taking screenshot
      - taking page screenshot
      -   disabled all CSS animations
      -   waiting for fonts to load...
      -   fonts in all frames are loaded
      - 2 consecutive screenshots matched
      - final screenshot did not match expectation - 20000 pixels (ratio 0.03 of all image pixels) are different
      - 20000 pixels (ratio 0.03 of all image pixels) are different

    Expected: /Users/andreylushnikov/tmp/test-results/a-should-work/should-work-1-expected.png
    Received: /Users/andreylushnikov/tmp/test-results/a-should-work/should-work-1-actual.png
        Diff: /Users/andreylushnikov/tmp/test-results/a-should-work/should-work-1-diff.png

      3 | test('should work', async ({ page }) => {
      4 |   await page.goto('file:///Users/andreylushnikov/prog/playwright/tests/assets/rotate-z.html');
    > 5 |   await expect(page).toHaveScreenshot();
        |                      ^
      6 | });
      7 |
```
2022-03-21 15:10:33 -07:00
Pavel Feldman
4aaa63beaa
test: add a test for #12837 (#12838) 2022-03-18 18:09:59 -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
Dmitry Gozman
009185bb89
fix(test runner): do not print fixture location without a separate timeout (#12894)
Otherwise, user randomly sees some "extend" calls that have no real meaning.
2022-03-18 16:09:41 -07:00
Dmitry Gozman
209bde5000
feat(test runner): descrbe.skip (#12865)
`describe.skip` declares a test group that is skipped.
2022-03-18 16:07:11 -07:00
Dmitry Gozman
3a009531b1
feat(hooks): add a step per hook (#12867)
It is now possible to see which hooks were run in the html report.
2022-03-17 19:33:01 -07:00
Dmitry Gozman
25483452c0
feat(fixtures): per-fixture timeout (#12751)
By default, fixtures share timeout with the test they are instantiated for.
However, for more heavy fixtures, especially worker-scoped ones, it makes
sense to have a separate timeout.

This introduces `{ timeout: number }` option to the list of fixture options
that opts the fixture into a dedicated timeout rather than sharing it
with the test.
2022-03-17 09:36:03 -07:00
Max Schmitt
e231db1810
chore: restore expect.any()/expect.anything() (#12820) 2022-03-16 21:34:41 +01:00
Andrey Lushnikov
88610c8b4c
fix: properly define apiName for web-first assertions (#12706)
Turns out relying on PWTRAP in stack is not reliable: depending on the
call structure, the stack might be cut unpredictably by Node.js.

This patch removes PWTRAP and instead plumbs explicit stack and
pre-set `apiName` all the way down to `wrapApiCall`.
2022-03-14 18:01:13 -07:00
Dmitry Gozman
237954212c
Revert "feat(line reporter): show stats, handle tty" (#12735)
This reverts commit be817d1a53, PR #12695.
Reason: found issues with stdout messing with stats.
2022-03-14 10:37:43 -07:00
Max Schmitt
adcd32fc6e
fix(expect): toHaveCSS with custom CSS properties (#12709) 2022-03-12 09:32:40 -08:00