Commit graph

1221 commits

Author SHA1 Message Date
sand4rt a62accf8ae
feat(ct): react rerender (#16549) 2022-08-15 13:10:38 -07:00
Pavel Feldman bd06d1604f
chore: render original exception location in error frame (#16515) 2022-08-15 09:28:55 -07:00
Elizaveta Bezyaikna 9f22ae9aa9
chore: add id for each test to JSONReporter (#16494) 2022-08-15 09:28:21 -07:00
Pavel Feldman e1d3246d1c
fix(ct): pass local config to preview (#16481) 2022-08-12 10:37:35 -07:00
Johannes Loher 3e67a7c836
feat(plugins): send accept header in webServer url checking (#16251) 2022-08-10 12:48:37 -07:00
Yury Semikhatsky d0030a7434
docs: test.step return value (#16421) 2022-08-10 11:21:13 -07:00
Dmitry Gozman baa2ef2700
fix(test runner): show interrupted as yellow (#16396)
Drive-by: fix unreadable character in "duplicate titles" error.
2022-08-09 21:17:30 -07:00
Dmitry Gozman f58c376443
fix(test runner): do not resolve relative imports through baseUrl (#16395) 2022-08-09 21:16:27 -07:00
Andrey Lushnikov 0c7f086096
chore: cut v1.25 branch (#16390) 2022-08-09 17:09:58 -07:00
Dmitry Gozman 2efe947dc8
chore: avoid evaluates in screenshot on failure (#16386) 2022-08-09 14:03:07 -07:00
Max Schmitt e725b5f8a9
fix(esm): fix TS type check with NodeNext mode (#16340) 2022-08-09 20:06:06 +02:00
Kian-Meng Ang 22f0723c72
docs: fix typos in docs (#16370)
Co-authored-by: Debbie O'Brien <debs-obrien@users.noreply.github.com>
Co-authored-by: Max Schmitt <max@schmitt.mx>
2022-08-09 15:47:17 +02:00
Jeremy Daley ee02afdd9b
chore: add fallback "default" key to "." exports object (#16350)
Fixes #16345.
2022-08-08 12:19:15 -07:00
Pavel Feldman a2e05bb419
fix(ct): use stoppable server (#16329) 2022-08-08 08:54:56 -07:00
Dmitry Gozman f6d94f0ac9
chore: update "X fatal errors" message (#16325)
Also, exlude certain errors from triggering this message:
- `no tests found`
- `duplicate test titles are not allowed`
- `--forbid-only found a focused test`
- `Timed out waiting 3600s for the entire test run`
2022-08-05 21:21:43 -07:00
Dmitry Gozman 7a86e140f5
chore: remove TestProject.projectSetup (#16321)
There are better ideas to address this issue in more general manner.
2022-08-05 15:24:30 -07:00
Dmitry Gozman 1f40e3d22b
chore: make Reporter.onExit an internal method (#16280) 2022-08-05 13:41:00 -07:00
Dmitry Gozman 424431fcfe
docs: explain toHaveText and toContainText in more details (#16283) 2022-08-05 10:27:17 -07:00
Dmitry Gozman cb30cb4eb7
feat(test runner): add --trace cli option (#16277) 2022-08-05 09:20:39 -07:00
Dmitry Gozman 919b1cbb22
fix(test runner): do not swallow afterEach errors after skipped tests (#16276)
Drive-by: add more test runner logging.
2022-08-04 18:49:23 -07:00
Pavel Feldman 3aa5710b49
feat(reuse): retain different browser types when reusing (#16269) 2022-08-04 15:04:00 -07:00
sand4rt bd5eddd62e
fix(ct): multi root vue components (#16211) 2022-08-04 10:43:43 -07:00
Pavel Feldman 7645ac25a0
chore: watch mode straw man (#16127) 2022-08-04 08:09:54 -07:00
sand4rt e5cc78af67
chore(ct): change setProps to rerender (#16204) 2022-08-03 18:14:00 -07:00
Pavel Feldman 8eca6339c2
feat(reuse): account for the browser launch args when reusing the bro… (#16229)
feat(reuse): account for the browser launch args when reusing the browsers
2022-08-03 17:32:29 -07:00
Dmitry Gozman 03fe75251b
fix(test runner): show tests as interrupted when maxFailures stops them (#16178)
Previously, we marked these tests as skipped, and it was sometimes
confusing, because they did actually run and produce some output/artifacts.
2022-08-03 15:25:25 -07:00
Dmitry Gozman 445fe032f5
feat(test runner): separate interrupted status from skipped (#16124) 2022-08-02 12:55:43 -07:00
Pavel Feldman de147fafba
chore: experimental project isolation mode (#16081) 2022-08-02 11:22:22 -07:00
Dmitry Gozman 5481e25015
chore: print full stacks when PWDEBUGIMPL is set (#16113)
For debugging purposes, especially on the client's computers.
2022-08-01 13:44:59 -07:00
Dmitry Gozman 3112edb4ca
feat(test runner): TestProject.projectSetup (#16063)
`projectSetup` is a project-scoped alternative to `globalSetup`.
It is only executed if at least one test from the project is scheduled to run.
2022-08-01 09:01:23 -07:00
Pavel Feldman 5a79054544
feat(innerloop): allow reusing browsers over the remote connection (#16065) 2022-07-31 14:31:17 -07:00
sand4rt 557db4c35e
chore(ct): mount result refactor (#16067) 2022-07-29 20:07:23 -07:00
Yury Semikhatsky 7d306bbc66
feat: return value from step (#16060) 2022-07-29 15:16:07 -07:00
Dmitry Gozman e830fe821d
feat(test runner): introduce test.describe.fixme (#16059) 2022-07-29 12:44:22 -07:00
Yury Semikhatsky af8e3e7afa
feat: print response text when toBeOK fails (#16040) 2022-07-29 11:46:48 -07:00
sand4rt 4a47e275c8
feat(ct): vue set props (#16058) 2022-07-29 11:45:06 -07:00
Pavel Feldman d73f9b7b88
chore: experimental test server implementation (#16033) 2022-07-29 11:40:33 -07:00
Dmitry Gozman 62e4e80599
feat(test runner): show the number of fatal errors at the end (#15975) 2022-07-28 14:46:21 -07:00
Max Schmitt a089bf3df5
chore(test-runner): better error message if page gets used inside beforeAll (#16012) 2022-07-28 23:07:28 +02:00
Dmitry Gozman 3d89506704
fix(fixtures): make undefined option mean "default value" (#16026)
In the following example, `locale` inside the `describe`
would be reverted to the default value:

```js
test.use({ locale: 'en-GB' });

test.decsribe(() => {
  test.use({ locale: undefined });
});
```
2022-07-28 12:57:05 -07:00
Pavel Feldman 8c190c3e09
feat(testId): expose persistent test id (#16003) 2022-07-27 20:17:19 -07:00
Pavel Feldman 2eff208e54
feat(ct): allow unmounting components (#15974) 2022-07-27 15:12:36 -07:00
Max Schmitt f663e5d6cc
chore: fix tests when repo checkout was not playwright (#15994) 2022-07-27 18:09:55 +02:00
Dmitry Gozman 6009804e0e
Revert "fix(test runner): ignore undefined values in fixtures definit…ions (#15119)" (#15979)
Revert "fix(test runner): ignore undefined values in fixtures definitions (#15119)"

Revert commit d7b63fa0b4.
Add a test for the broken behavior.
2022-07-27 08:51:45 -07:00
Dmitry Gozman cd9dccbe27
fix(test runner): serial suites inside parallel suite should run in parallel (#15769) 2022-07-26 13:38:25 -07:00
Dmitry Gozman c0d78c5642
fix(runner): friendly error message instead of "digests do not match" (#15939) 2022-07-26 08:53:32 -07:00
Dmitry Gozman 9ce727c936
feat(list reporter): number test runs to see testing progress (#15693)
Drive-by: replace a few colors.gray with colors.dim for better contrast.
2022-07-25 13:22:25 -07:00
Dmitry Gozman f88b1e9cde
feat(reporters): separate onExit from onEnd (#15926)
This is now used by html reporter to open UI.
2022-07-25 13:20:33 -07:00
Max Schmitt 004cd9273c
fix(test-runner): multiple webServer types (#15901) 2022-07-25 10:39:06 +02:00
Dmitry Gozman f954891491
fix(runner): globalTeardown without globalSetup should work (#15814) 2022-07-20 12:41:35 -07:00
Max Schmitt 507e921371
chore: bump 'ip' peer dependency (#15750) 2022-07-18 20:04:26 +02:00
Dmitry Gozman a56d801352
fix(test runner): show fixture name when worker times out (#15724) 2022-07-15 13:05:48 -07:00
Yury Semikhatsky 582b5e08b2
docs: clarify toHaveURL parameter semantics (#15723) 2022-07-15 11:09:20 -07:00
Dmitry Gozman da2fdc2e2e
fix(esm loader): support Node 18.6 (#15694)
A small change in the API requires `shortCircuit: true` when returning the
transformed source.
Another API change removes third argument from the chained resolve/load,
but passing three instead of two still works.
2022-07-14 19:10:39 -07:00
Max Schmitt 4bba41ab8f
Revert "feat(matchers): add toContainClass (#15491)" (#15670)
This reverts commit e4debd0bf6.
2022-07-14 22:03:37 +02:00
Andrey Lushnikov df9beb4045
chore: cut v1.24 (#15654) 2022-07-14 09:42:40 -07:00
Pavel Feldman d02914fa3a
chore: relax transpilation criteria to allow ems imports of .vue files (#15592) 2022-07-13 16:11:38 -07:00
Dmitry Gozman 22ead7b5ab
Revert "fix(test runner): handle istty in line reporter (#15455)" (#15633)
This reverts commit 767babc3a2.
2022-07-13 15:11:56 -07:00
Dmitry Gozman 51c3ea55ed
Revert "feat(line reporter): show testing progress (#15547)" (#15631)
This reverts commit e76d9b3b28.
2022-07-13 13:54:26 -07:00
Max Schmitt ee7d60fcee
docs: migrate page actions to locator actions 2/n (#15603) 2022-07-13 11:50:18 +02:00
Pavel Feldman 00848b1bcf
fix(ct): restore public folder deployment (#15594) 2022-07-12 16:14:48 -07:00
Yury Semikhatsky a6daf600a9
fix: support hasColors and getColorDepth in worker (#15590) 2022-07-12 14:47:14 -07:00
Pavel Feldman 3939b9f36e
chore: migrate component testing to server-side page reuse (#15477) 2022-07-12 14:30:24 -07:00
Max Schmitt e4debd0bf6
feat(matchers): add toContainClass (#15491) 2022-07-12 23:17:10 +02:00
Pavel Feldman f3d3231b29
feat(ct): allow configuring apps per test (#15551) 2022-07-12 09:37:33 -07:00
Dmitry Gozman 64353c4b96
fix(test runner): make sure worker cleans up if last test was skipped (#15552) 2022-07-11 21:33:56 -07:00
Dmitry Gozman e76d9b3b28
feat(line reporter): show testing progress (#15547)
Line reporter now shows stats in addition to the test name:
```
[chromium] › page/page-click-react.spec.ts:108:1 › should not retarget when element changes on hover
[21/93] Passed: 17 Flaky: 0 Failed: 0 Skipped: 4 (7s)
```
2022-07-11 20:44:50 -07:00
Dmitry Gozman 7727ebe758
feat(html report): improve test list view (#15543)
- Two lines per test: title and location.
- Align project labels.
- Add trace badge that opens trace viewer.
- Add video and image diff badges that show scrolled test result view.
2022-07-11 19:47:15 -07:00
Pavel Feldman 3a9b29f46c
feat(ct-vue): allow configuring apps per test (#15538) 2022-07-11 13:54:05 -07:00
Pavel Feldman 5fc637e44a
chore: experimental resetForReuse (#15432) 2022-07-11 13:10:08 -07:00
Max Schmitt 98ea418124
fix(expect): expect.not types (#15487) 2022-07-11 18:31:53 +02:00
Pavel Feldman dd0eb5fb1d
fix(ct): support components w/o mount options (#15501) 2022-07-09 11:22:49 -07:00
Dmitry Gozman 6dc4a51c92
fix(test runner): more friendly test duration (#15476)
fix(test runner): more firendly test duration

Reported test duration now does not include time spent in
`beforeAll`, `afterAll` and fixtures that have a separate timeout.

This is to avoid different reported test execution time,
depending on the test execution order.
2022-07-08 11:45:44 -07:00
Dmitry Gozman 894ead5198
fix(test runner): mention fixture in worker teardown timeout error message (#15499) 2022-07-08 11:44:37 -07:00
Yury Semikhatsky 51aa5fea78
fix: colors in console output from worker (#15421)
Color highlights regressed in #14455

Fixes #15366
2022-07-07 17:56:41 -07:00
Dmitry Gozman 738d71ebc2
chore: unify two copies of monotonicTime (#15473) 2022-07-07 15:59:49 -07:00
Ross Wollman 799d4703bc
feature(test-runner): multiple web servers (#15388)
Fixes #8206.

Since #8206 is a long-awaited (~ 1 year old), popular (~ 45 reactions, frequently requested in community channels, etc.), this PR aims to unblock folks.

Notably, we do not innovate on the `webServer` API, despite knowing we're not in love with it. We'll save the innovation for either Plugins or a new `LaunchConfigs` option. (We haven't yet arrived at a Plugin API we like, and instead of launching a new option guessing what the "better" launchConfig API would be, let's wait and see how folks use this new Array-variant of `webServer` which—despite its name—can be used for non-Web Server launches!
2022-07-07 15:27:21 -07:00
Dmitry Gozman 767babc3a2
fix(test runner): handle istty in line reporter (#15455)
When running without tty, line reporter outputs a line for each
percent of the tests, thus limiting the output to ~100 lines.

In addition, reporters now support PLAYWRIGHT_LIVE_TERMINAL
env variable to force tty mode.
2022-07-07 09:55:12 -07:00
Dmitry Gozman 89c16cbc8b
feat(runner): anonymous describes (#15424)
Useful to set some options without coming up with an artificial name.

```js
test.describe(() => {
  test.use({ colorScheme: 'dark' });

  test('my test', () => {});
})
```
2022-07-06 13:54:11 -07:00
Pavel Feldman 1b264010db
fix(ct): tolerate compiled react components (#15422) 2022-07-06 13:44:06 -07:00
Dmitry Gozman c02d83fb11
fix(runner): filter only after duplicate titles check (#15401) 2022-07-06 12:51:26 -07:00
Dmitry Gozman ee82837fb5
fix(fixtures): do not run user function when required fixture has failed (#15385)
Currently, it is possible to run a function, e.g. a second `beforeEach` hook,
that will receive `null` for the fixture that has already failed before.

This PR skips running any user function that uses a fixture that has already
failed, just like if the fixture would be initialized again and failing for
the second time.
2022-07-05 17:15:28 -07:00
Ross Wollman 981f5ab8c1
fix(test-runner): apply fixme v. skip annotations (#15277)
Currently, if `text.fixme()` or `test.skip()` is used within a test, we
add a `fixme` or `skip` annotation. However, if the wrapper style is
used:

```
test.fixme('should work', () => {…})
```

the annotations were missing. This change adds annotations for the
above.

These annotations are important for reporting purposes and knowing
exactly what flavor of "skipped" was used.

Fixes #15239.
2022-07-05 10:46:30 -07:00
Sergio Freire 71c08a5dcf
fix(junit reporter): embedding attachments on report didnt work for tests outside root folder (#15359) 2022-07-05 10:35:14 -07:00
Dmitry Gozman 2a805c1f1c
fix(line reporter): print currently running test (#15339) 2022-07-05 09:07:55 -07:00
Pavel Feldman 295ea7a3cb
fix(config): fall back to context options (#15309) 2022-07-01 10:20:13 -07:00
Pavel Feldman c4d2342339
fix(config): fall back to launch options (#15293) 2022-07-01 08:12:57 -07:00
Dmitry Gozman 5083da9d98
test: unflake "should truncate long test names" (#15286) 2022-06-30 20:24:00 -07:00
Pavel Feldman 6425ab9e78
fix(ff): allow more time to launch browser (#15290) 2022-06-30 18:07:25 -07:00
Dmitry Gozman b86926e691
fix(test runner): update timeout error messages (#15117)
Some of the current timeout error messages are confusing, because they do not suggest that the issue is most likely a slow test. This PR updates timeout messages as follows:
- Test timeout of 30000ms exceeded.
- Test timeout of 30000ms exceeded while setting up "browser".
- Test timeout of 30000ms exceeded while tearing down "context".
- Test timeout of 30000ms exceeded while setting up "playwright configuration".
- Test timeout of 30000ms exceeded while running "beforeEach" hook.
- Test timeout of 30000ms exceeded while running "afterEach" hook.
- "beforeAll" hook timeout of 30000ms exceeded.
- "afterAll" hook timeout of 30000ms exceeded.
- Worker teardown timeout of 30000ms exceeded.
- "skip" modifier timeout of 30000ms exceeded.
- Fixture "myCustomFixture" timeout of 5000ms exceeded.
2022-06-30 17:05:08 -07:00
Max Schmitt 3d1d723c56
fix(esm): show codeframe when errors get reported (#15262) 2022-06-30 21:17:08 +02:00
Pavel Feldman 28f382bea6
chore: roll source-map-support to 0.5.21 (#15237)
Co-authored-by: Max Schmitt <max@schmitt.mx>
2022-06-29 19:47:45 +02:00
Dmitry Gozman 79163e802a
fix(test runner): screenshot immediately after failure (#15159)
Previously, screenshot was taken after hooks and fixtures teardown.
However, hooks can easily modify the state of the page, and
screenshot would not reflect the moment of failure.

Instead, we take screenshots immediately after the test function
finishes with an error.
2022-06-27 17:46:39 -07:00
Dmitry Gozman d7b63fa0b4
fix(test runner): ignore undefined values in fixtures definitions (#15119)
These mean "I don't want to specify this fixture/option"
instead of "I want the value of undefined", aligned with how TypeScript works.
We already do similar things in the config.
2022-06-27 11:31:41 -07:00
Dmitry Gozman a93db3cf11
fix(reporter): line reporter should not swallow half-line stdout (#15114) 2022-06-27 11:25:42 -07:00
Dmitry Gozman a46aaee6e8
fix(reporters): truncate long test titles from the start (#15052)
Most useful information is at the end - test name, current step, retry.
We truncate the repetitive project + suites at the start.
2022-06-22 17:03:54 -07:00
Pavel Feldman 9525bedc1f
feat(har): re-add routeFromHAR (#15024) 2022-06-21 22:12:37 -07:00
Dmitry Gozman c02e165eb6
fix(test runner): toHaveScreenshot should not overwrite matching expectations (#15028)
Even in the `--update-snapshots` mode we should keep existing files if
they are matching under the threshold, to avoid needless churn.
2022-06-21 18:01:25 -07:00
Max Schmitt 3a61938628
chore: mark 1.24-next (#14857) 2022-06-21 19:32:15 +02:00
Ross Wollman 0f8114f6a8
docs: replace serviceWorkers workaround (#14902) 2022-06-20 19:31:19 -07:00
Pavel Feldman 5e6b493bc9
doc(har): add more details into the har doc (#14998) 2022-06-20 17:54:39 -07:00
Dmitry Gozman 5397394653
feature(har): add testOptions.har (#14991)
Can now be used with `test.use({ har })`.
Also added more tests for latest har features.
2022-06-20 13:37:31 -07:00
Pavel Feldman 1b927f1214 chore: remove stray log 2022-06-18 17:27:31 -07:00
Pavel Feldman e8070ee1b2
chore: warn users on clashing test output and html reporter folders (#14964) 2022-06-18 15:47:26 -07:00
Max Schmitt 08ac966f68
fix(html-reporter): do not verbose yell when opening report without gui (#14935) 2022-06-17 18:38:23 +02:00
Ross Wollman b9114f9cbc
fix(html-reporter): file-browser friendly extensions (#14943)
Fixes #14904.

This is done to make looking at the raw contents of the report
friendlier when using a file browser. However, it should be noted, the
public API of the HTML Reporter makes no guarantees of its contents
structure/layout/naming-conventions.
2022-06-17 08:09:49 -07:00
Pavel Feldman 59fa61aef1
fix(ct): relax react import pattern (#14896) 2022-06-15 16:14:45 -07:00
Ross Wollman 112a18e083
docs: document new webServer "ready" status codes (#14885)
Sync docs with implementation introduced via 30f3d526eb
2022-06-15 09:00:29 -07:00
marlowl 9d9b5d13be
docs(class-testconfig.md): remove trailing devices reference (#14867) 2022-06-14 13:25:06 -07:00
Ross Wollman 61536098be
docs: fix serviceWorkers formatting (#14845) 2022-06-13 15:18:24 -07:00
Pavel Feldman 88664c39c9
chore: remove esm error interception, it only confuses users (#14829) 2022-06-13 12:32:42 -07:00
Max Schmitt 18795ac034
fix: rewrite source-map-support Buffer deprecation warning (#14836) 2022-06-13 19:50:21 +02:00
Pavel Feldman 41529bb1a5
chore: respect sigint in global setup (#14805) 2022-06-12 13:06:00 -07:00
Pavel Feldman 76abb3a5be
chore: unify tab generation (#14802) 2022-06-10 17:34:31 -07:00
Pavel Feldman 380e787065
fix(ct): respect boolean shorthands (#14798) 2022-06-10 17:34:21 -07:00
Pavel Feldman 30f3d526eb
feat(server): consider 3XX, 400-403 responses as started server 2022-06-10 14:47:29 -07:00
Sergio Freire 060cd9d97c
feat(junit reporter): link testcases to Xray test issues and provide additional metadata for Xray Test Management (#11374)
Co-authored-by: Sergio Freire <sergio.freire@xpand-it.com>
2022-06-10 10:31:48 +02:00
Sergio Freire d193bd64c4
feat(junit reporter): add option to force usage of CDATA sections for content in XML elements (#12744)
Co-authored-by: Sergio Freire <sergio.freire@xpand-it.com>
2022-06-10 10:25:52 +02:00
Josh Bowling 8dc10556e8
chore: fix error message typo (#14729) 2022-06-09 10:03:11 -04:00
Ross Wollman 85d03714d9
feat: add allow/block serviceWorkers option (#14714)
Adds cross-browser support for easily allowing/blocking Service Workers via a Context option.

Includes plumbing for Playwright Test's `use`.

Resolves #14522.

Relates #1090.
Supercedes #14321.
2022-06-08 18:27:51 -04:00
Pavel Feldman ca2afaaebd
chore: update babel (#14646) 2022-06-06 15:49:31 -07:00
Dmitry Gozman 1c6a136909
docs: describe test.setTimeout inside beforeAll/afterAll (#14670)
Adding documentation that `test.setTimeout()` call from the
`beforeAll`/`afterAll` hook changes the timeout of the hook itself.
2022-06-06 15:18:38 -07:00
Pavel Feldman 2d5572abd8
fix(ct): return locator to root for fragments (#14639)
fix(fragments): return locator to root for fragments
2022-06-04 14:07:06 -07:00
Pavel Feldman c4b003a29a
chore: don't mask ESM error (#14628) 2022-06-03 15:28:53 -07:00
Dmitry Gozman 79d356f0cc
fix(test runner): when worker exits unexpectedly, fail a single test (#14608)
All remaining tests will continue in a new worker.
2022-06-02 21:13:47 -07:00
Pavel Feldman 74b846270b
feat(ct): support Vue2 (#14600) 2022-06-02 17:37:43 -07:00
Ross Wollman 978854b859
chore: move multi-select assertion to toHaveValues (#14595)
Follow-up to e0a87e52d7
2022-06-02 16:01:34 -04:00
Dmitry Gozman 3a3aa023ad
chore: simplify context/page reuse in ct (#14565) 2022-06-02 12:16:07 -07:00
Andrey Lushnikov 8801f79742
Revert "fix(playwright-test): prohibit async functions passed to describe (#14538)" (#14591)
This reverts commit bd0fe50a0e.
2022-06-02 10:31:10 -07:00
Andrey Lushnikov bd0fe50a0e
fix(playwright-test): prohibit async functions passed to describe (#14538)
References #14533
2022-06-02 09:44:47 -07:00
Ross Wollman e0a87e52d7
feat: support multi-select/combo box with toHaveValue (#14555) 2022-06-02 12:10:28 -04:00
Dmitry Gozman d00efa0dfe
feat(expect): add ignoreCase option to toHaveText and toContainText (#14534) 2022-06-02 05:52:53 -07:00
Pavel Feldman e912b6897d
fix(esm): respect source maps in esm-transpiled code (#14561) 2022-06-01 16:50:23 -07:00
Pavel Feldman 95672765bc
fix(ct): isolate component tests when recording video / trace (#14531) 2022-05-31 15:59:36 -07:00
Dmitry Gozman a7500c18d6
feat(test runner): allow serial suites inside parallel (#14530)
Also works for `fullyParallel` mode.
2022-05-31 15:24:20 -07:00
Yury Semikhatsky 2bcdf68ef5
fix(runner): do not override trace files in afterAll (#14529) 2022-05-31 15:21:51 -07:00
Andrey Lushnikov 582a18e4dc
chore: add more information to debug worker early exits (#14499)
References #14498
2022-05-31 05:48:06 -07:00
Yury Semikhatsky 9f47160673
fix: do not override console object in worker (#14455) 2022-05-29 09:46:19 -07:00
Yury Semikhatsky c1aecc7d50
docs: maxDiffPixels description typo (#14456) 2022-05-29 09:46:06 -07:00
Pavel Feldman f724fa570f
docs: make ts snippets esm-friendly (#14451) 2022-05-27 12:36:59 -07:00
Yury Semikhatsky b164d82ba3
fix(runner): ignore .gitignore if testDir is explicitly configured (#14430)
If the tests are in an explicitly configured testDir (either at the global config level or per project) .gitignore filters are not applied.

Fixes #14381
2022-05-26 14:39:51 -07:00
Pavel Feldman 6efb1ec40c
fix(ts): export types explicitly (#14428) 2022-05-26 13:09:32 -07:00
Pavel Feldman ea07ff3ae9
fix(jsx): allow passing variables into mount (#14412) 2022-05-25 13:59:45 -07:00
Ross Wollman cfc9aa64a6
chore: produce meaningful bundle notice diffs (#14396) 2022-05-24 22:19:54 -07:00
Pavel Feldman 9440f52b88
feat(ct): support cra w/ .js (#14326) 2022-05-24 19:43:28 -07:00
Pavel Feldman d97c9bd5b6
test(ct): start covering components with tests (#14369) 2022-05-24 13:54:12 -07:00
Ross Wollman 9b225f2ad4
fix: expect.toHaveScreenshot.animations types (#14387)
This makes the docs/types match the code which has already been
released.

Relevant code to traverse up from:
- 3e084829c0/packages/playwright-core/src/server/screenshotter.ts (L89)
- 3e084829c0/packages/playwright-core/src/server/screenshotter.ts (L118)

Fixes #14385
2022-05-24 11:34:29 -07:00
Andrey Lushnikov 3fd435d1d3
docs: fix docs for toHaveScreenshot (#14280) 2022-05-24 10:54:32 -07:00
Pavel Feldman 71a55c74da
fix(leak): do not retain test fixtures in worker fixtures (#14363) 2022-05-23 16:54:56 -07:00
Pavel Feldman 99f5eff400 fix(ct): do not break if there are no components (2) 2022-05-23 14:37:56 -07:00
Pavel Feldman 3c2d7d3bf2
fix(ct): do not break if there are no components (#14362) 2022-05-23 14:33:16 -07:00
Pavel Feldman 432c52d31a
chore: more testing-friendly trace (#14264) 2022-05-18 14:35:16 -07:00
Pavel Feldman 738d5e5b3e
chore: pass fixture defaults different from falsy (#14237) 2022-05-18 12:03:47 -07:00
Pavel Feldman 4d9ef46f64
fix(ct): recreate context on option change (#14243) 2022-05-18 09:57:05 -07:00
Pavel Feldman e4d55fd061
fix: include @types/node in pwt deps (#14230) 2022-05-17 20:36:35 -07:00
Max Schmitt 9256de5f48
chore: fix wrong toHaveScreenshot defaults in docs (#14200) 2022-05-16 22:26:23 +03:00
Pavel Feldman 56a5f2c506
fix(types): fix the toHaveScreenshot types (#14174)
Co-authored-by: Andrey Lushnikov <aslushnikov@gmail.com>
2022-05-16 07:53:46 -07:00
Dmitry Gozman c3beb71b07
fix(test runner): do not run automatic fixtures for beforeAll hooks (#14104)
There are a few issues this covers:
- Some fixtures like `page` and `context` are not allowed in `beforeAll`
  hooks, so using them in automatic fixture makes it throw.
- Running automatic fixture solely for `afterAll` is unexpected.
  This currently happens when `afterAll` is run for cleanup after
  fixture timeout/throw.

For built-in playwright fixture, we keep `'all-hooks-included'` auto mode.

Added a doc explaining the execution order.
2022-05-13 11:17:20 +01:00
Andrey Lushnikov f7adbd83ee
chore: cut v1.22.0 (#14098) 2022-05-12 11:12:01 -07:00
Max Schmitt 9693635c86
chore: remove babel__parser (#14096) 2022-05-11 15:31:48 +01:00
Dmitry Gozman 305afcdacf
fix(test runner): fix duplicate titles error when multiple issues are present (#14090) 2022-05-11 11:53:16 +01:00
Pavel Feldman 39489931d1
chore: add more ct options to allow redirecting templates/cache (#14077) 2022-05-10 12:21:29 -07:00
Ross Wollman 0c9e0d22df
fix(ct): preserve context changes (#13986)
1. add test (and fix) using context fixture with mount
2. add test for innerText that was failing prior to https://github.com/microsoft/playwright/pull/14008
2022-05-10 11:45:47 -07:00
Dmitry Gozman e8fb5a6337
fix(test runner): ensure that hooks run before fixtures teardown after timeout (#14035)
We had common cleanup exiting early after timeout, because we did not
reset the time slot.
2022-05-09 20:38:20 +01:00
Pavel Feldman e9378ba5fc
chore: hide plugins again (#14038) 2022-05-09 10:06:13 -07:00
Pavel Feldman 46e82e8fea
feat(ct): only rebuild when necessary (#14026) 2022-05-09 09:10:47 -07:00
Andrey Lushnikov 5aa82dc5e4
chore: un-experiment expect(pageOrLocator).toHaveScreenshot() (#14033)
This patch un-experiments `expect(pageOrLocator).toHaveScreenshot()`
method.

Fixes #13526
2022-05-09 08:34:03 -07:00
Pavel Feldman a052211dbf
chore: do not reset internal bindings for reuse (#14019) 2022-05-09 07:44:20 -07:00
Andrey Lushnikov 98945a81a8
feat: move toHaveScreenshot to use old snapshot paths by default (#14006)
Note: all toHaveScreenshot tests still use `__screenshots__` directory
for their expectations. One more test was added to make sure that
by default, `toHaveScreenshot` uses old snapshots.
2022-05-09 07:34:53 -07:00
Pavel Feldman 5c9e7f48e0
fix(debug): do not pause on internal calls, update ct docs (#14018) 2022-05-07 19:56:25 -07:00
Andrey Lushnikov d711734d38
chore: cleanup stray "fonts" mention in the codebase (#14016)
This is a follow-up to #14004
2022-05-07 09:16:55 -07:00
Pavel Feldman b8c4f426cc
chore: return source map from registry generator (#14005) 2022-05-06 18:29:49 -07:00
Pavel Feldman dc36b0158a
chore: dedupe ct fixtures (#14002) 2022-05-06 14:53:38 -07:00
Pavel Feldman 1bbefce9af
Revert "chore: use plugins for component testing again (#13977)" (#13998)
This reverts commit a2f9f15e3e.
2022-05-06 12:02:07 -07:00
Pavel Feldman a2f9f15e3e
chore: use plugins for component testing again (#13977) 2022-05-05 14:26:56 -07:00
Pavel Feldman 058f32caff
chore: fixtures-via-plugin implementation (#13950) 2022-05-05 10:14:00 -07:00
Ross Wollman 95f7acf1e4
chore: widen Metadata type (#13942) 2022-05-04 13:16:11 -07:00
Andrey Lushnikov aaedf1c8ea
fix(testrunner): explicitly define viewport size fixture (#13801)
Instead of relying on library defaults, let's explicitly define
viewport size fixture so that users can rely on its existance.
2022-05-04 09:17:33 -07:00
Pavel Feldman 214117c9c5
clean: speed up ct (#13915) 2022-05-03 21:25:50 -07:00
Pavel Feldman 13224d1c9f
chore: restore component testing options (#13910) 2022-05-03 15:48:46 -07:00
Pavel Feldman 29fd1d86df
chore: hide plugins for now (#13908) 2022-05-03 14:25:56 -07:00
Dmitry Gozman 85b86e19b8
feat(expect): ensure it works in global setup (#13896) 2022-05-03 21:53:15 +01:00
Pavel Feldman 19ce4e3514
chore: refactor web server plugin to extract legacy (#13904) 2022-05-03 11:47:37 -07:00
Dmitry Gozman ef32069299
chore: small test runner changes in preparation of global fixtures (#13899)
The main change is splitting up options from the config from other
fixtures to ensure unique location for them.
2022-05-03 15:19:27 +01:00
Dmitry Gozman 4f5fbea26f
chore: get rid of ProjectImpl (#13894) 2022-05-03 13:36:24 +01:00
Ross Wollman 3b3cad7d69
feat: rewrite gitCommitInfo plugin, drop GlobalInfo & attachments (#13837) 2022-05-02 16:28:14 -07:00
Dmitry Gozman d87de8c52c
fix(test runner): restore --headed flag (#13872) 2022-05-02 16:55:14 +01:00
Pavel Feldman a1b10c3856
chore: try serializing the config instead of requiring it in the worker (#13839) 2022-04-29 16:05:08 -07:00
Pavel Feldman 46acf84c68
chore: pass config w/ cli overrides to plugins (#13835) 2022-04-29 13:32:39 -07:00
Pavel Feldman 18bff137ce
chore: remove default config from cli (#13832) 2022-04-28 16:49:36 -07:00
Ross Wollman 4984878411
fix: await plugin.configure (#13834) 2022-04-28 16:22:20 -07:00
Ross Wollman f486ce8c06
feat(plugins): add webServer implementation (#13779) 2022-04-28 15:08:10 -07:00
Ross Wollman 45972a0b6a
feat: add name for plugins (#13826)
Useful for debugging and eventually for reporters to give status updates on which phase of which plugin they are currently running.
2022-04-28 11:43:39 -07:00
Pavel Feldman e756528ad2
feat(plugins): expose suite to plugin setup (#13807) 2022-04-28 08:16:17 -07:00
Dmitry Gozman b9f47558b5
feat(reporters): show failures on CI when adding dot automatically (#13814) 2022-04-28 12:29:21 +01:00
Pavel Feldman a01b65bedd
chore: drop the legacy global setup mode (#13803) 2022-04-27 18:01:37 -07:00
Dmitry Gozman 3aba94dbef
chore: remove unnecessary types from overrides-test (#13794) 2022-04-27 16:14:37 +01:00
Pavel Feldman bc6f8e1f20
feat(poll): expose custom poll interval (#13776) 2022-04-26 21:32:38 -07:00
Pavel Feldman 2bc36794d1
chore: vite all frameworks (#13780) 2022-04-26 16:15:08 -07:00
Max Schmitt 37bee74ae5
chore: set minimum version to Node.js 14 (#13469) 2022-04-26 17:52:32 +02:00
Pavel Feldman 5e51c17d41
chore: use plugin story for components (#13717) 2022-04-25 10:40:58 -07:00
Yury Semikhatsky 2e6ef8f622
fix(runner): fail if worker cannot find some of the tests (#13666) 2022-04-25 09:05:40 -07:00
Dmitry Gozman 8e5854033a
fix: types generation for attach and GlobalInfo (#13727) 2022-04-25 13:56:37 +01:00
Ross Wollman 3eac9c694c
fix(test-runner): mark attach as async (#13687)
Also brings back generation of experimental types as part of lint.
2022-04-22 09:27:02 -07:00
Pavel Feldman 3d4caab153
chore: move playwright gallery into a subfolder (#13695) 2022-04-21 21:07:43 -07:00
Pavel Feldman 5990eb6074
chore: use vite plugin for registry (#13658) 2022-04-21 17:30:17 -07:00
Pavel Feldman 207c3c7abc
fix: dep bring back core dependency (#13632) 2022-04-19 08:31:31 -07:00
Andrey Lushnikov 88a9262dbb
fix: resolve WebServer cwd dir wrt configDir (#13626)
Drive-by: speed-up webserver tests by not waiting 750ms to start it.

Fixes #13115
2022-04-19 07:45:36 -07:00
Andrey Lushnikov a617604962
test: make sure toHaveScreenshot doesn't tolerate bad option values (#13627)
Fixes #13495
2022-04-19 07:43:18 -07:00
Pavel Feldman 007e908cd9
chore: bundle pwt deps (#13622) 2022-04-18 21:47:18 -07:00
Pavel Feldman 7989427ea6
chore: bundle core deps (#13621) 2022-04-18 20:20:49 -07:00
Pavel Feldman 63ea81ec54
chore: make bundles typed (#13620) 2022-04-18 17:50:25 -07:00
Yury Semikhatsky ed0dcdabc9
docs: clarify toBeDisabled behavior (#13616) 2022-04-18 17:06:01 -07:00
Pavel Feldman 58d79e5e4d
chore: add core utils bundle (#13615) 2022-04-18 13:47:23 -07:00
Pavel Feldman 4f0103fef0
chore: babel, expect, zip bundles (#13588) 2022-04-18 11:31:58 -07:00
Pavel Feldman eafb92f6a3
chore: embed expect types (#13609) 2022-04-18 10:54:40 -07:00
Ross Wollman 71fbd2454e
fix(test-runner): avoid premature stop of worker in fullyParallel (#13584)
Prior to this change, we were pre-maturely stopping a worker (since it
was deemed redundant under a race condition), and then we immediately
created a new worker with the same hash to finish off the test run. The
worker creation is expensive, so this slowed down the overall test run
time.

See the following for logs of the old code illustrating the extra stops and starts: https://gist.github.com/rwoll/1c592ed9e8f9169274fa972674de6703
2022-04-17 16:22:57 -07:00
Yury Semikhatsky 7ffce1da53
chore: remove PlaywrightClient and Docker factory (#13571) 2022-04-15 12:11:38 -07:00
Dmitry Gozman 02aa4fe617
chore: generate types for TestProject/TestConfig (#13574) 2022-04-15 10:27:38 -07:00
Dmitry Gozman 189a5fa0f8
chore: freez FullProject public type (#13570)
This is similar to FullConfig.
Properties `expect` and `fullyParallel` are not exposed.
2022-04-14 16:58:01 -07:00
Yury Semikhatsky aee6ba299a
chore: remove GridClient, run only page tests in service mode (#13566) 2022-04-14 15:30:04 -07:00
Wojciech Jureczka 7ba527c65f
chore: expose JSON Reporter types (#13241)
Resolves #13208
2022-04-14 13:55:29 -07:00
Dmitry Gozman c86c2e8762
feat: restore toHaveScreenshot as experimental feature (#13549)
- Restore docs.
- Make `TestConfig.expect` generated.
- Allow experimental properties with "e" marker: `- foo e<float>`.
2022-04-14 13:22:42 -07:00
Dmitry Gozman 20dcc45afa
feat: support experimental doc entries (#13446)
feat: support experimental doc entries

- Params/options/members are marked as experimental in the docs.
- `experimental.d.ts` is generated that contains all types and
  includes experimental features.
- `experimental.d.ts` is references in our tests so that we
  can test experimental features.
- `fonts` option is restored as experimental.
2022-04-13 16:13:30 -07:00
Dmitry Gozman 166675b9c1
feat(test): more information about timing out fixtures (#13546)
- Always show a fixture that was running during timeout.
- Give custom titles to built-in fixtures.
- Specify setup/teardown fixture phase in the message.
- Split connect vs launch browser fixtures for better naming.

Example timeout message:

```log
Timeout of 2000ms exceeded while running fixture "built-in playwright configuration" teardown.
```
2022-04-13 15:13:31 -07:00
Dmitry Gozman 1e1df6395f
chore: generate expect types (#13439) 2022-04-11 10:42:19 -07:00
Dmitry Gozman f6ccd4847e
fix(test runner): default workerIndex to -1 (#13440) 2022-04-08 15:23:23 -07:00
Yury Semikhatsky 9712b9ee08
fix: match against secure path (#13442) 2022-04-08 14:57:43 -07:00
Dmitry Gozman 916dd1e698
feat(remote): handle timeout manually in browser fixture (#13406)
To make launch/connect not affect the test timeout:
- `browser` fixture is declared with `timeout: 0`.
- Default timeouts are set to 30sec for launch and 3min for connect.
2022-04-08 13:39:12 -07:00
Ross Wollman 1af32e400f
feat(test-runner): introduce GlobalInfo (#13083) 2022-04-08 13:22:14 -07:00
Pavel Feldman e79b90f454
chore: use utils via index export (5) (#13413) 2022-04-07 20:18:22 -07:00
Dmitry Gozman cef476b89f
docs: support optional methods (#13415)
So far, these are used in `Reporter`.
2022-04-07 18:51:05 -07:00
Andrey Lushnikov 91333daf09
chore: cut v1.21.0 (#13405) 2022-04-07 18:16:22 -07:00
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
Pavel Feldman dbafe3bb4e
chore: use utils via index export (1) (#13398) 2022-04-07 13:26:50 -07:00
Yury Semikhatsky 32d30ae71d
chore: fix assert imports (#13359) 2022-04-06 21:30:48 -07:00
Dmitry Gozman c68f57d2d0
docs: mark optional properties/arguments explicitly with "?" (#13369)
Previously, we were guessing whether something is optional from the
comment (looking for stuff like "defaults to" or "optional").

To remove this error-prone technique, every optional property or
argument (but not option) is explicitly marked with "?".
2022-04-06 19:02:10 -07:00
Pavel Feldman c80365dd43
chore: distill deps after import types update (#13367) 2022-04-06 15:41:08 -07:00
Pavel Feldman 5ae2017a5b
chore: always import type (#13365) 2022-04-06 14:57:14 -07:00
Pavel Feldman 1c3db811f5
chore: move to folder-based deps lists (#13361) 2022-04-06 14:40:19 -07:00
Ivan Kaliada 424de6c38f
fix: resolve ts compilerOptions.paths with prefixes and suffixes (#13105) 2022-04-06 14:14:03 -07:00
Dmitry Gozman 4123a55be5
chore: generate more types (#13358)
As a result, fix documentation issues:
- Removed `TestStep.data` that is not a thing.
- Added `TestConfig.name` documentation.
- Refined a lot of optional types in the documentation.
- Aligned `test.fail()` and `test.slow()` docs with `test.skip()`.
- Strict set of docs vs types inconsistensies in the generator
2022-04-06 13:36:20 -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 a71c151438
chore: introduce FullProjectInternal (#13301)
This is similar to FullConfigInternal to put private stuff on.
2022-04-04 16:07:04 -07:00
Dmitry Gozman a09b8dfa36
chore: unrelease 'fonts' screenshot option (#13300) 2022-04-04 14:51:11 -07:00
Thomas Scholtes 3e65ef35cf
fix: wait for worker to be ready before initializing (#13270)
fix: wait for worker to be ready before initializing

The test dispatcher waits until a worker is ready before sending the
`init` message. This guarantees that the worker process is listening for the
message. Otherwise, the worker process might miss the `init` message and
the subsequent `run` message would crash the worker.
2022-04-04 13:56:57 -07:00
Pavel Feldman 1bebc28aed
chore: reset page/context for reuse in component tests (#13264) 2022-04-04 12:39:43 -07:00
Dmitry Gozman f6936c0461
chore: move private fields to FullConfigInternal (#13261) 2022-04-01 18:32:34 -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
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
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 923f74c5a6
chore: allow matchers decorate step title (#13199) 2022-03-30 21:52:00 -07:00
Dmitry Gozman ecc804d808
chore: prepare types to stricter checks in TS 4.7.0 (#13193) 2022-03-30 20:33:36 -07:00
Yury Semikhatsky c200321402
fix: export request from index.jsm (#13158) 2022-03-30 09:35:47 -07:00
Andrey Lushnikov a9989852d5
feat(vrt): new option "caret" for taking screenshots (#13164)
This has two values:
- `"hide"` to hide input caret for taking screenshot
- `"initial"` to keep caret behavior unchanged

Defaults to `"hide"`.

Fixes #12643
2022-03-29 17:48:13 -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
Pavel Feldman 5575476697
chore: make webserver try index.html for / (#13155) 2022-03-29 12:19:56 -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
Pavel Feldman 8758cf8cbf
chore: migrate html reporter to vite (#13116) 2022-03-28 18:21:19 -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
Ross Wollman ae365dda3b
chore: remove internal dep on FullConfig (#13074)
Resolves #13058.

This blocks adding #8206 since we don't want the new launch configs
publicly available on FullConfig.
2022-03-28 15:53:42 -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 6b81e76c2b
chore: migrate trace-viewer and recorder to vite (#13076) 2022-03-25 14:12:00 -07:00
Pavel Feldman 3f1cb7b8e6
chore: only restart esm on Node 16+ (#12955) 2022-03-25 08:44:42 -07:00
Pavel Feldman 81d412216a
fix: list files when config writes to output (#13023) 2022-03-25 08:44:27 -07:00
Pavel Feldman 07c1a27732
chore(deps): prepare deps for monorepo (#13057) 2022-03-25 08:43:29 -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
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 2a7370bad2
fix: upgrade json5 dependency (#12946)
Fixes #12940
2022-03-22 11:33:23 -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 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
Henrik Storck 05387b7835
fix: fix folder traversal for isModule check (#12836) (#12837) 2022-03-16 15:52:39 -08: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
Andrey Lushnikov e3bd7ce119
fix(test-runner): resolve outputDir wrt rootDir (#12755)
Currently, running `npx playwright test` in a subfolder of your project
will result in a `test-results` folder created in your `cwd`.

This is unexpected; instead, we should always resolve all paths
against `rootDir` - directory that contains config.
2022-03-14 17:20:17 -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
Andrey Lushnikov ef4b34fb7a
feat(toHaveScreenshot): enhance messaging in case of failures (#12677)
This patch:
- adds call logs to track screenshot timeouts, e.g. due to
  waiting for web fonts
- makes sure all snapshot expectations have `.png` extension
- throws a polite error when given a buffer or a string instead of a
  page or a locator
- removes stray NL between error description and call log
- makes sure `apiName` is always correct (and adds a test for it)
2022-03-11 22:40:28 -08:00
Dmitry Gozman be817d1a53
feat(line reporter): show stats, handle tty (#12695)
- Line reporter now shows stats in addition to the test name:
  ```log
  [chromium] › page/page-click-react.spec.ts:108:1 › should not retarget when element changes on hover
  23% [21/93] Passed: 17 Flaky: 0 Failed: 0 Skipped: 4 (7s)
  ```

- When connected to a TTY or with `env.PLAYWRIGHT_LIVE_TERMINAL`
set to anything but `'0'` or `'false'`, line reporter updates in place.

- When not connected to a TTY, line reporter prints an update
after each ~1% of tests done, so it never prints more than 100 lines.

- Updated tests to the golden style.
2022-03-11 18:19:33 -08:00
Pavel Feldman e9fa098bf3
chore: add ct examples (#12693) 2022-03-11 15:46:11 -08:00
Andrey Lushnikov 95c774cf84
feat: support multiple screenshots in HTML report (#12577)
This patch adds support to multiple diffs. These are possible
due to soft assertions.

Drive-by: rename second screenshot in `toHaveScreenshot` failure when
re-generating expectations from "expected" to "previous".
2022-03-11 08:46:13 -08:00
Andrey Lushnikov e3ab6388a9
feat(toHaveScreenshot): enable sensible defaults (#12675)
This patch:
- Enables configuration of certain defaults for some options of `expect.toHaveScreenshot` method via `TestProject.expect.toHaveScreenshot` property
- Sets sensible defaults for these options:
  * `fonts: "ready"`
  * `animations: "disabled"`
  * `size: "css"`
2022-03-11 08:45:36 -08:00
Pavel Feldman af55f48754
chore: add experimental mount (#12657) 2022-03-11 08:00:46 -08:00
Ross Wollman ebae5e76df
feat(test-runner): more default workers for M1 (#12660)
New default is based on the very (unscientific) output of repeated a few
times:

```
$ for i in `seq 5 13`; do time npm run ctest -- --reporter=line --workers=$i 'page/*' 'selector*' 'channels*' 'resource-timing*'; done
```
2022-03-11 02:12:07 -08:00
Andrey Lushnikov b51157bdea
feat: bring back maxDiffPixels in toMatchSnapshot (#12627)
This patch reverts 2 commits that removed the feature from the method:
- "fix: explicitly ignore maxDiffPixels in toMatchSnapshot (#12570)"
  commit b8af8458d6.
- "chore: remove `maxDiffPixels` from toMatchSnapshot (#12539)"
  commit a3dff45974.
2022-03-10 18:41:16 -08:00
Andrey Lushnikov 12d8a262be
feat: support screenshotsDir option (#12642)
The `screenshotsDir` option controls the expectation storage
for `toHaveScreenshot()` function.

The new expectation management for screenshots has the following
key properties:
- All screenshots are stored in a single folder called `screenshotsDir`.
- Screenshot names **do not** respect `snapshotDir` and `snapshotSuffix`
  configurations.
- `screenshotsDir` is configurable per project. This way a "smoke tests"
  project can re-use screenshots from "all tests" project.
- Host platform is a top-level folder.

For example, given the following config:

```js
// playwright.config.ts
module.exports = {
  projects: [
    { name: 'Mobile Safari' },
    { name: 'Desktop Chrome' },
  ],
};
```

And the following test structure:

```
smoke-tests/
└── basic.spec.ts
```

Will result in the following screenshots folder structure by default:

```
__screenshots__/
└── darwin/
    ├── Mobile Safari/
    │   └── smoke-tests/
    │       └── basic.spec.ts/
    │           └── screenshot-expectation.png
    └── Desktop Chrome/
        └── smoke-tests/
            └── basic.spec.ts/
                └── screenshot-expectation.png
```
2022-03-10 16:50:26 -08:00
Pavel Feldman 4d3d0e2bda
chore: enable ts-esm support by default (#12658) 2022-03-10 14:48:33 -08:00
Max Schmitt 3f468abedd
fix(test-runner): ESM compatibly on Windows (#12615) 2022-03-10 19:27:25 +01:00
Andrey Lushnikov 75eef09c0d
feat: show expectation name as part of toHaveScreenshot title (#12612)
This patch adds snapshot file name as part of `toHaveScreenshot`
and `toMatchSnapshot` step title.
2022-03-09 20:09:45 -08:00
Dmitry Gozman 92430cc56c
chore(fixtures): do not force-close contexts in beforeAll (#12416)
This now happens the same way as for the test, in the worker cleanup
when browser closes, which is reported as a part of the test.
2022-03-09 07:26:46 -08:00
Dmitry Gozman e8ce5d0258
feat(test runner): on beforeAll failure, precisely skip the tests (#12417)
Previously, we used to skip all the tests from the same file when
any `beforeAll` fails in the file.

Now, we only skip the rest of the tests affected by this particular
`beforeAll` and continue with other tests in the new worker.
2022-03-08 20:29:31 -08:00
Dmitry Gozman 4a768294b4
chore: cleanup hooks notion from raw/html reporters (#12610) 2022-03-08 19:08:31 -08:00
Dmitry Gozman e895bc2751
reland(test-runner): rely on test title paths instead of ordinal (#12611)
Fixes #11904

Co-authored-by: Andrey Lushnikov <lushnikov@chromium.org>
2022-03-08 19:06:25 -08:00
Dmitry Gozman 682eeb4ae0
reland(hooks): separate test timeout from beforeAll/afterAll timeouts (#12609)
This makes it possible to have longer `beforeAll`/`afterAll` and not
affect first/last test timeout.
2022-03-08 19:05:23 -08:00
Yury Semikhatsky 176846672f
docs: clarify multiple before/after hooks execution order (#12606) 2022-03-08 17:42:50 -08:00
Dmitry Gozman 9cd704220c
reland(test runner): run hooks/modifiers as a part of the test (#12518)
Reland: worker.stop() before worker.run() was hanging because
`_runFinished` promise was not initially resolved.
---
This moves `beforeAll`, `afterAll` and some modifiers from running
as a separate entity into running inside a test.

Pros:
- All errors are reported as test errors.
- All artifacts are collected as test artifacts.
- Reporters support this out of the box.

Details:
- Each test computes the necessary hooks to run and runs them.
- Teardown is usually performed during the test (on test failure or worker stop).
- `skipRemaining` is added to `DonePayload` to preserve the behavior
  where `beforeAll` hook failure skips subsequent tests.
  This behavior can now be improved to only target tests affected by this hook.
2022-03-08 16:35:14 -08:00
Andrey Lushnikov 4bccf2f6aa
chore: cut v1.20 branch (#12593) 2022-03-08 14:01:20 -08:00
Andrey Lushnikov b8af8458d6
fix: explicitly ignore maxDiffPixels in toMatchSnapshot (#12570)
Fixes #12564
2022-03-07 16:55:35 -08:00
Andrey Lushnikov a3dff45974
chore: remove maxDiffPixels from toMatchSnapshot (#12539)
References #12441
2022-03-04 18:27:04 -08:00
Andrey Lushnikov 4953fc4845
chore: introduce toHaveScreenshot configuration options (#12507)
References https://github.com/microsoft/playwright/issues/12441
2022-03-04 17:30:43 -08:00
Andrey Lushnikov 1f5cfcaeec
fix(to-have-screenshot): show number of bad pixels in mismatched error (#12502)
Drive-by: do not show empty call log.

References #12441
2022-03-04 11:01:05 -08:00
Basarat Ali Syed dd83ece3cb
chore(test-runner): correct warning instruction for port reuse (#12479) 2022-03-04 10:14:49 +01:00
Andrey Lushnikov 279e579097
chore: address pixelCount and pixelRatio review comments (#12501)
- documentation fixes
- rename pixelCount to maxDiffPixels
- rename pixelRatio to maxDiffPixelRatio
2022-03-03 23:17:31 -08:00
Pavel Feldman 34bf0d4b87
feat(test-runner): allow grepping in project (#12469) 2022-03-02 15:02:35 -08:00
Pavel Feldman 4b19d59ec5
feat(test): introduce fully parallel mode (#12446) 2022-03-01 18:12:21 -08:00
Pavel Feldman b79bb32c82
chore: do not stall on actions when test timeout is 0 (#12418) 2022-03-01 13:43:38 -08:00
Pavel Feldman a612a3526a
chore: auto-detect ts esm mode (#12292) 2022-03-01 12:56:26 -08:00
Max Schmitt 5b7db90cb6
chore: hide unsupported expect methods (#12403) 2022-03-01 20:04:34 +01:00
Pavel Feldman 96945ab0a2
chore: do not print empty attachments in terminal (#12419) 2022-03-01 09:11:53 -08:00
Pavel Feldman 6a663ef54f
chore(test-runner): revert recent changes to fix tests (#12439)
* Revert "fix(hooks): separate test timeout from beforeAll/afterAll timeouts (#12413)"

This reverts commit 73dee69558.

* Revert "fix(test-runner): rely on test title paths instead of ordinal (#12414)"

This reverts commit d744a87aee.

* Revert "chore(test runner): run hooks/modifiers as a part of the test  (#12329)"

This reverts commit 47045ba48d.
2022-03-01 09:11:17 -08:00
Andrey Lushnikov d744a87aee
fix(test-runner): rely on test title paths instead of ordinal (#12414)
Fixes #11904
2022-02-28 15:40:23 -08:00
Dmitry Gozman 73dee69558
fix(hooks): separate test timeout from beforeAll/afterAll timeouts (#12413)
This makes it possible to have longer `beforeAll`/`afterAll` and not
affect first/last test timeout.
2022-02-28 15:09:04 -08:00
Andrey Lushnikov 396d920145
feat(test-runner): implement expect(pageOrLocator).toHaveScreenshot (#12242)
Fixes #9938
2022-02-28 12:25:59 -08:00
Dmitry Gozman 47045ba48d
chore(test runner): run hooks/modifiers as a part of the test (#12329)
chore(test runner): run hooks/modifiers as a part of the test

This moves `beforeAll`, `afterAll` and some modifiers from running
as a separate entity into running inside a test.

Pros:
- All errors are reported as test errors.
- All artifacts are collected as test artifacts.
- Reporters support this out of the box.

Details:
- Each test computes the necessary hooks to run and runs them.
- Teardown is usually performed during the test (on test failure or worker stop).
- `skipRemaining` is added to `DonePayload` to preserve the behavior
  where `beforeAll` hook failure skips subsequent tests.
  This behavior can now be improved to only target tests affected by this hook.
2022-02-28 11:42:47 -08:00
Dmitry Gozman 3c2bca2768
fix(test loader): implement tsconfig paths through resolveFilename (#12357)
This uses `Module._resolveFilename` to intercept module resolution and
check `tsconfig.paths` similarly to pirates usage ot `Module._compile`.

Previously, we resolved during compilation that required reproducible
resolution due to caching. Now we can resolve as we go and support
all `tsconfig.paths`.
2022-02-25 15:43:58 -08:00
Dmitry Gozman 91672595f2
fix(reporters): normalize usage of isTTY, env.CI and debug env variables (#12295)
- `stdout.isTTY` controls whether list reporter updates lines or just adds them;
- `env.CI` is used in a few places to affect the defaults:
  - whether to open interactive html;
  - default reporter dot/line;
  - default terminal reporter added to non-terminal reporters;
- `env.PWTEST_SKIP_TEST_OUTPUT` is removed;
- `env.PW_TEST_DEBUG_REPORTERS` is introduced specifically for tests.
2022-02-24 12:39:28 -08:00
Andrey Lushnikov 71edad327b
fix: tolerate EBUSY error when removing output directories (#12323)
- Previous attempt: https://github.com/microsoft/playwright/pull/12300
- Revert with reasoning: ebc52d10e4

Fixes #12106
2022-02-23 14:23:57 -08:00
Andrey Lushnikov df7fbe7857
Revert "chore: best-effort cleanup for output folders that are mounted (#12300)" (#12321)
This reverts commit e5c9d1e39f.

Reason for revert: turns out this fix results in a 5-second delay
when starting tests in docker, with `test-results` folder being
a non-removable mount.

The reason for the delay is the `maxBusyTries` option that we
supply by default to rimraf when trying to remove the folder.

While this option might come handy when removing temporary
browser profile folder, it doesn't serve us well in this particular
usecase.

References #12106
2022-02-23 14:10:11 -08:00
Andrey Lushnikov 5879c7f362
chore: refactor toMatchSnapshot once again (#12313)
Keep massaging code in preparation for `toHaveScreenshot`.

References #9938
2022-02-23 13:17:37 -08:00
Andrey Lushnikov e5c9d1e39f
chore: best-effort cleanup for output folders that are mounted (#12300)
Fixes #12106
2022-02-23 12:55:41 -08:00
Dmitry Gozman 4399623f9f
chore(test runner): make timeout a separate error in TestInfo.errors (#12315)
This way we control the timeout error message from the runner,
so that later on we can differentiate between test timeout, fixture
timeout and hook timeout.
2022-02-23 12:32:12 -08:00
Dmitry Gozman 114edecd3a
fix(list mode): keep outputDir intact (#12291) 2022-02-22 12:50:26 -08:00
Dmitry Gozman d3c4323021
fix(test runner): improve error message for unexpected calls (#12240) 2022-02-18 18:25:18 -08:00
Dmitry Gozman ee0dd6ec71
fix(test runner): trim full output path (#12239)
Previously, we only trimmed the "full title" component, but
we should also trim the "relative path" component.
2022-02-18 15:40:36 -08:00
Andrey Lushnikov 0682672242
chore: move comparator logic to playwright-core (#12232)
This will enable implementation of `toHaveScreenshot` on the
server-side.

Drive-by: drop blink-diff

References #9938
2022-02-18 14:39:17 -08:00
Andrey Lushnikov b9e86b79ee
chore: refactor toMatchSnapshot implementation (#12206)
This patch prepares for the `toHaveScreenshot` implementation
by splitting common parts from `toMatchSnapshot`.

Drive-by: fix default extension generation from `.bin` to `.dat`
for unknown buffers.
2022-02-18 11:21:58 -08:00
Dmitry Gozman edac84d072
feat(remote): send browser/channel/headless in a header (#12205) 2022-02-18 07:54:33 -08:00
Dmitry Gozman 34eec7eae7
fix(webServer): route output through reporters (#12198) 2022-02-18 07:54:01 -08:00
Andrey Lushnikov a98babec69
feat(test-runner): introduce pixelCount and pixelRatio options (#12169)
This patch adds additional options to `toMatchSnapshot` method:
- `pixelCount` - acceptable number of pixels that differ to still
  consider images equal. Unset by default.
- `pixelRatio` - acceptable ratio of all image pixels (from 0 to 1) that differ to still
  consider images equal. Unset by default.

Fixes #12167, #10219
2022-02-17 15:44:03 -08:00
Pavel Feldman 51344c6924
chore: parse-skip .tsx (#12143) 2022-02-16 15:45:35 -08:00
Andrey Lushnikov 086333cd60
feat(test-runner): support unnamed snapshots (#12161)
Fixes #9007
2022-02-16 14:22:01 -08:00
Andrey Lushnikov ef21ce3f56
feat(test-runner): filter out syntax error stack traces (#12095)
Filter out long stack traces from babel when it fails compilation
due to syntax error in test.
2022-02-14 14:33:14 -08:00
Dmitry Gozman 9814c592d2
fix(test runner): shutdown redundant workers (#12062) 2022-02-14 10:57:15 -08:00
Pavel Feldman 96b5831a49
chore: add support private methods in TS (#12051) 2022-02-11 14:46:49 -08:00
Dmitry Gozman d8db785c0a
fix(reporters): correctly handle missing stdout.columns (#12016)
When columns are not available, do not trim the output.
2022-02-11 08:33:56 -08:00
Pavel Feldman ea590c6f67
fix(teardown): await teardown in failed test runs (#12012) 2022-02-10 12:44:42 -08:00
Ross Wollman 0d42c16a17
fix(test-runner): undefined body crash with manual attachments (#11995)
The new (as of 1.18) `async testInfo.attach(…)` API handles this
gracefully (and is part of the reason for the new API's existence).
However, for the foreseeable future, it's still possible to manually
push onto the attachments array where we can't validate the contents
until it's too late, so this change ensures more graceful handling in
that case.

Fixes #11565
2022-02-10 12:33:38 -08:00
Pavel Feldman fbc05b74a7
chore: revert "fix(test-runner): escape backslashes in win cli (#11763)" (#12004) 2022-02-10 07:02:37 -08:00
Andrey Lushnikov 6904b3294e
fix(test-runner): fix browser initialization in test modifiers (#11984)
Fixes #11985
2022-02-09 15:30:14 -08:00
Yury Semikhatsky 706c897031
feat(fixtures): respect tracing config for APIRequestContext (#11954) 2022-02-09 08:54:09 -08:00
Pavel Feldman e9e5de2d57
feat(debug): allow preprocessing JS scripts as well (#11953) 2022-02-09 07:14:11 -08:00
Dmitry Gozman 19368e93af
feat(test runner): support connectOptions (#11919)
This allows to specify `connectOptions` in the config that
switch built-in `browser` to be remotely connected.
2022-02-08 20:45:42 -08:00
Dmitry Gozman 5881a46ecf
fix(test runner): skip beforeAll/afterAll when all tests are skipped (#11952)
There is a corner case where tests were skipped like this:

```js
test.skip('title', () => {});
```
2022-02-08 16:36:30 -08:00
Andrey Lushnikov 3eba252f2e
chore: cut v1.19.0 (#11944) 2022-02-08 16:01:44 -08:00
Dmitry Gozman e92caf01b3
fix(webServer): do not set baseURL equal to webServer.url (#11951) 2022-02-08 15:57:36 -08:00
Pavel Feldman 8dff2e35c8
chore: don't throw on no testDir (#11950) 2022-02-08 15:27:05 -08:00
Pavel Feldman d5158e8d24
chore: revert source-map-support to 0.4.18 (#11945) 2022-02-08 14:50:20 -08:00
Pavel Feldman 4bcca2c87e
chore: add a parallel mode note (#11943) 2022-02-08 14:36:14 -08:00
Dmitry Gozman 8a5c93436d
fix(reporter): do not report parallel tests as slow (#11921) 2022-02-07 20:10:13 -08:00
Dmitry Gozman 7912c515a3
fix(fixtures): account for default options being undefined (#11916) 2022-02-07 17:11:36 -08:00
Pavel Feldman 9116adc684
chore: allow opt-into the legacy global setup mode (#11888) 2022-02-07 10:41:56 -08:00
Yury Semikhatsky 46dfa45b4e
docs: fix parallel test docs build (#11877) 2022-02-04 16:44:04 -08:00
Yury Semikhatsky afc4b505aa
docs: fix duplicate sections (#11874) 2022-02-04 13:50:46 -08:00
Dmitry Gozman d9a8bb057d
fix(test-fail): allow unhandled expects in test.fail (#11850)
Previously, we would consider this a worker error, but
we make an exception for "expect()" calls.
2022-02-03 17:14:12 -08:00
Pavel Feldman 72424dc904
chore: allow setting reporter via env (#11848) 2022-02-03 16:10:39 -08:00
Pavel Feldman fdda759a9d
feat(parallel): allow setting enclosing scope parallel mode (#11822) 2022-02-02 20:44:11 -08:00
Andrey Lushnikov ba0c7e679b
feat(test-runner): support expect.soft (#11800)
Soft expects will still fail the test, but will not abort it's execution. As a consequence of this:
-  `TestResult` now might have multiple errors, which is reflected with a new `testResult.erros: TestError[]` field.
- `TestInfo` now might have multiple errors as well, which is reflected with a new `testInfo.errors: TestError[]` field.

Fixes #7819
2022-02-02 18:33:51 -08:00
Max Schmitt c752b28516
chore: pin production dependencies (#11793) 2022-02-02 11:14:41 +01:00
Andrey Lushnikov b0daa7754f
feat: filter stack traces to exclude test runner frames (#11795)
Before:

```bash
Running 1 test using 1 worker
  1) [chromium] › tests/example.spec.ts:3:1 › should work ==========================================

    Error: expect(received).toBe(expected) // Object.is equality

    Expected: 2
    Received: 1

      2 |
      3 | test('should work', async({page}) => {
    > 4 |   expect(1).toBe(2);
        |             ^
      5 | });
      6 |

        at Proxy.<anonymous> (/Users/andreylushnikov/prog/playwright/packages/playwright-test/src/expect.ts:151:30)
        at /Users/andreylushnikov/tmp/tests/example.spec.ts:4:13
        at /Users/andreylushnikov/prog/playwright/packages/playwright-test/src/workerRunner.ts:335:13
        at runNextTicks (node:internal/process/task_queues:61:5)
        at processImmediate (node:internal/timers:437:9)
        at TestInfoImpl._runFn (/Users/andreylushnikov/prog/playwright/packages/playwright-test/src/testInfo.ts:164:7)
        at WorkerRunner._runTestWithBeforeHooks (/Users/andreylushnikov/prog/playwright/packages/playwright-test/src/workerRunner.ts:317:24)
        at TimeoutRunner.run (/Users/andreylushnikov/prog/playwright/packages/playwright-core/src/utils/async.ts:48:14)
        at TestInfoImpl._runWithTimeout (/Users/andreylushnikov/prog/playwright/packages/playwright-test/src/testInfo.ts:151:7)
        at WorkerRunner._runTestOrAllHook (/Users/andreylushnikov/prog/playwright/packages/playwright-test/src/workerRunner.ts:276:5)
        at WorkerRunner._runSuite (/Users/andreylushnikov/prog/playwright/packages/playwright-test/src/workerRunner.ts:190:11)
        at WorkerRunner.run (/Users/andreylushnikov/prog/playwright/packages/playwright-test/src/workerRunner.ts:137:9)
        at process.<anonymous> (/Users/andreylushnikov/prog/playwright/packages/playwright-test/src/worker.ts:87:5)
```

after:

```
Running 1 test using 1 worker
  1) [chromium] › tests/example.spec.ts:3:1 › should work ==========================================

    Error: expect(received).toBe(expected) // Object.is equality

    Expected: 2
    Received: 1

      2 |
      3 | test('should work', async({page}) => {
    > 4 |   expect(1).toBe(2);
        |             ^
      5 | });
      6 |

        at /Users/andreylushnikov/tmp/tests/example.spec.ts:4:13
```
2022-02-01 18:40:44 -08:00
Pavel Feldman ceb3027bdf
chore(test-runner): force colors in worker processes (#11799) 2022-02-01 17:29:15 -08:00
Pavel Feldman 6e2fcc4700
chore: do not expose suite load error (#11797) 2022-02-01 15:34:16 -08:00
Pavel Feldman f875ebe730
fix(test-runner): respect source maps when reporting test files (#11770) 2022-02-01 13:04:54 -08:00
Max Schmitt 028afb167b
chore: bump production dependencies (#11787) 2022-02-01 21:27:34 +01:00
Pavel Feldman a3bc911a3d
fix(debug): don't apply infinite timeouts when using debugger (#11785) 2022-02-01 11:51:37 -08:00
Caio Agiani b6b60decdf
fix: typos (#11789) 2022-02-01 11:09:41 -08:00
Pavel Feldman 3a5e8184b5
fix(html-reporter): open tests from required file (#11784) 2022-02-01 11:01:52 -08:00
Pavel Feldman c82f2641d7
fet(list-files): report per-project test dir and filters (#11764) 2022-02-01 08:08:56 -08:00
Pavel Feldman c5d852f1bb
fix(test-runner): escape backslashes in win cli (#11763) 2022-01-31 17:48:05 -08: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
Pavel Feldman 2b55adaafa
feat(breaking): always report onBegin/onEnd, report file errors (#11758) 2022-01-31 17:09:04 -08:00
Andrey Lushnikov 3a4e506479
chore: extract SigIntWatcher (#11749)
This is to reduce the size of the long `_run` method in the `runner.ts`.
It also might come handy around the codebase.
2022-01-31 08:51:22 -08:00
Andrey Lushnikov b58b004f0f
fix: run reporter.onEnd after webserver teardown (#11712)
Fixes #11647
2022-01-31 06:19:33 -08:00
Dmitry Gozman eeebcd53ae
chore(test runner): extract TestInfoImpl (#11725) 2022-01-28 17:39:42 -08:00
Dmitry Gozman 30f3cbd6da
fix(fixtures): make sure defaultLaunchOptions are always there (#11713) 2022-01-28 10:51:55 -08:00
Pavel Feldman 29a84b2df8
chore: allow pre-processing scripts (#11702) 2022-01-27 14:32:23 -08:00
Feng Yu 0698254253
docs: fix broken link (#11687)
fix #11680
2022-01-27 13:00:09 -08:00
Dmitry Gozman b1fbc4fdbe
fix(test runner): resolve tsconfig for each file (#11662)
This allows us to properly handle path mappings
that are not too ambiguous.
2022-01-26 18:28:42 -08:00
divdavem 512a245f13
feat(test-runner): wait for a url before starting tests (#10138)
The webServer configuration in @playwright/test now accepts a url as an
alternative to a port number to wait for a url to return a 2xx status code.
2022-01-26 16:32:58 -08:00
Dmitry Gozman 19820de7a9
fix(test runner): correctly save videos when running remotely (#11633) 2022-01-26 07:43:07 -08:00
Dmitry Gozman 4f42484c64
chore(test runner): simplify runTestWithBeforeHooks (#11629) 2022-01-25 16:46:50 -08:00
Dmitry Gozman 800b813d4b
chore(test runner): prepare to per-fixture timeout (#11605)
This reworks DeadlineRunner to use exception to signal timeout. This way,
we'll be able to run fixtures against a shared deadline vs their own
deadline and still get an easy control-flow timeout handling.
2022-01-25 11:22:28 -08:00
Andrey Lushnikov 42876a0528
fix: support PWDEBUG=0 to disable debug (#11611)
Fixes #11606
2022-01-25 08:40:24 -08:00
Ross Wollman 64e7557fb9
fix: falsey behavior in route.continue, page.post, testInfo.attach (#11421)
In several of the Playwright APIs, falsey values were not handled correctly. This changeset adds tests (and some fixes):

- route.continue: If options.postData was the empty string, the continue failed to override the post data.
- page.post (application/json with options.data: false|''|0|null): Raw falsey values were getting dropped (i.e. you can't do the equivalent of curl --header application/json … -d 'false'). This has been fixed with most values across all browsers, but an additional fix is needed for 'null' which the channel serializer treats extra specially.
- testInfo.attach: This didn't get reported as an error when options.path was the empty string, but should have been.
#11413 (and its fix #11414) inspired this search as they are the same
class of bug.
2022-01-24 15:06:36 -08:00
Pavel Feldman 9542b007cf
fix(esm): don't emit module shorthand warning (#11596) 2022-01-24 11:22:56 -08:00
Pavel Feldman 0b99d83911
chore: include config dir in quick list report (#11563) 2022-01-22 17:02:46 -08:00
Pavel Feldman baf0e5b47a
chore: implement lightweight test listing (#11551) 2022-01-21 19:11:22 -08:00
Pavel Feldman 6b3e596fd8
fix(baseurl): support path-less baseurl (#11527) 2022-01-20 18:11:56 -08:00
Pavel Feldman 50fa839e64
chore: include transpilation mode in the compute cache hash (#11521) 2022-01-20 13:33:40 -08:00
Ross Wollman 33f32368e5
fix(test runner): dispatcher transformation of empty attachments (#11414) 2022-01-17 18:47:24 -08:00
Pavel Feldman 8ecf581b45
chore: focus by line should override only (#11427) 2022-01-16 08:47:09 -08:00
Pavel Feldman 8b0ef4ad6b
chore: introduce oop testing mode for debugging (#11428) 2022-01-15 19:25:32 -08:00
Max Schmitt badb5b4d13
chore(pw-test): forward web-server stdout to debug target (#11384) 2022-01-13 23:55:46 +01:00
Dmitry Gozman 9d5bf0e90d
fix(test runner): fixture teardown double error, testInfo.attach() (#11365)
- Use file path, not content to calculate the attachment hash.
- Always cleanup fixture from the list on teardown, to avoid reporting
  teardown error multiple times: from the test, and from the cleanup.
2022-01-13 10:38:47 -08:00
Pavel Feldman feb7148b3f
chore: don't write into stdout from the test runner, use reporters instead (#11367) 2022-01-12 19:52:40 -08:00
Andrey Lushnikov 9285596806
chore: cut v1.18.0 (#11358)
Drive-by: fix the `//utils/bump_package_versions.js` script.
2022-01-12 11:50:44 -08:00
Andrey Lushnikov 6f932fcb4a
fix: default list reporter should dump stderr to stderr (#11351)
This is consistent with all other reporters we have in place.
2022-01-12 07:43:25 -08:00
Dmitry Gozman 4efb30999f
feat(request): show request context methods as steps (#11337) 2022-01-11 17:33:41 -08:00
Andrey Lushnikov 2a0930c7a4
docs: clarification about trailing slash in docs (#11326)
Fixes #10557
2022-01-11 07:50:58 -08:00
Dmitry Gozman da1f39fb29
chore(test runner): refactor worker runner parts (#11316)
This will make it easier to change in the future.
2022-01-10 20:25:56 -08:00
Dmitry Gozman d36ff8a96c
fix(test runner): remove test output for failures (#11308) 2022-01-10 13:22:09 -08:00
Dmitry Gozman 14fd837e94
fix(test runner): hide beforeAll/afterAll hooks from the reporter api (#11306)
This api is not ready yet.
2022-01-10 12:09:51 -08:00
Andrey Lushnikov 7b1fecc009
fix: default to en-US locale in all browsers in Playwright Test (#11133)
It makes sense to default to en-US by default across all our browsers in Playwright Test.

Fixes #11127
2022-01-10 08:37:55 -08:00
Michaël De Boey ff5f75dc10
fix: pin colors to 1.4.0 (#11274) 2022-01-09 16:18:21 -08:00
Dmitry Gozman 058f98d3dd
fix(test runner): revert error location from top frame (#11250)
This does not play nicely with some internal Playwright errors, so
it needs more tweaks.
2022-01-07 11:06:47 -08:00
Dmitry Gozman 19460d50e4
chore(test runner): process-wide cache of required test files (#11230)
This is a preparation to TestRunner api, where we should be
able to run tests multiple times in the same runner process.
2022-01-06 15:38:10 -08:00
Pavel Feldman 373042ed89
chore: don't allow importing @playwright/test twice (#11218) 2022-01-06 09:29:05 -08:00
Dmitry Gozman 3ecac56cc0
fix(test runner): testInfo.attach api review changes (#11211)
Remove overload, require name, merge options.
2022-01-05 16:39:33 -08:00
Dmitry Gozman f77c874e8a
feat(test runner): make _extendTest experimental (#11210)
Hidden from types and docs.
2022-01-05 15:54:00 -08:00
Dmitry Gozman ccc61e31ea
chore(test runner): preparation for TestRunner api (#11209) 2022-01-05 15:49:01 -08:00
Dmitry Gozman 3839917eb6
chore(test runner): move config loading to runner (#11186)
In preparation for the TestRunner api.
2022-01-05 13:44:29 -08:00
Dmitry Gozman 16a779a5ff
fix(test runner): show codeframe and location from the error top stack frame (#11179)
Previously, reporter would look for a stack frame directly in the test file.
Often times, that is not a top stack frame, especially when the test uses
some helper functions.

This changes error snippets and locations to use the top frame. When top
frame does not match the test file, we additionally show the location
to avoid confusion:

```
  1) a.spec.ts:7:7 › foobar ========================================================================

    Error: oh my

       at helper.ts:5

      3 |
      4 |       export function ohMy() {
    > 5 |         throw new Error('oh my');
        |               ^
      6 |       }
      7 |

        at ohMy (.../reporter-base-should-print-codeframe-from-a-helper/helper.ts:5:15)
        at .../reporter-base-should-print-codeframe-from-a-helper/a.spec.ts:8:9
        at FixtureRunner.resolveParametersAndRunHookOrTest (.../src/fixtures.ts:281:12)
```
2022-01-04 16:00:55 -08:00
Pavel Feldman 7bfa6f9b5f
feat(html): group similar items in the report (#11160) 2022-01-03 21:17:17 -08:00
Pavel Feldman a0aeaeb929
test: expose repeatEachIndex (#11158) 2022-01-03 17:29:54 -08:00
Ross Wollman dadb5cbc30
fix(html reporter): fix too much strikethrough in diffs (#11115)
Textual snapshot diffs were previously broken in the HTML Report. The strikethrough'd text extended beyond the intended region.

HTML Report Before: 
<img width="693" alt="Screen Shot 2021-12-27 at 4 43 35 PM" src="https://user-images.githubusercontent.com/11915034/147518750-a60f9002-6eed-48a1-a412-20fabd076fa6.png">

HTML Report After:
<img width="206" alt="Screen Shot 2021-12-27 at 4 48 37 PM" src="https://user-images.githubusercontent.com/11915034/147518762-19a4c8f9-ccc3-4a3c-a962-5a42edc6fc5d.png">

This now matches what's expected and shown in the terminal (which has always been correct):

<img width="1384" alt="Screen Shot 2021-12-27 at 4 36 29 PM" src="https://user-images.githubusercontent.com/11915034/147518799-f538259e-5a45-4d6f-916c-a12ccb620c5b.png">

NB: This MR is a workaround, but not a root cause fix. It works, but I never fully got to the root cause so a bug upstream may be required. It's unclear whether it's (1) in [`colors`](https://www.npmjs.com/package/colors), (2) in [`ansi-to-html`](https://www.npmjs.com/package/ansi-to-html), or (3) Playwright's use of the two. Since the terminal output is correct, I suspect it is in `ansi-to-html`. For example:

```js
const colors = require("colors");
const Convert = require('ansi-to-html');
const convert = new Convert();

// original (strike incorrectly wraps everything in the HTML)
console.log(convert.toHtml(colors.strikethrough("crossed out") + ' ' + colors.red("red")))
// prints: <strike>crossed out <span style="color:#A00">red<span style="color:#FFF"></span></span></strike>

// workaround
console.log(convert.toHtml(colors.reset(colors.strikethrough("crossed out")) + ' ' + colors.red("red")))
// prints: <strike>crossed out</strike> <span style="color:#A00">red<span style="color:#FFF"></span></span>
```

Fixes #11116
2021-12-28 09:56:34 -08:00
Dmitry Gozman f933759ad1
chore(test runner): minor improvements (#11067)
- Types for fixture options and more.
- Refined type for deadline runner.
2021-12-22 09:59:58 -08:00
Dmitry Gozman f5304e3bda
fix(fixtures): await fixture teardown when shutting down the worker (#11033) 2021-12-20 16:19:21 -08:00
Dmitry Gozman 2d00836f0e
fix(test runner): show the location of afterAll timeout (#11007) 2021-12-18 09:32:41 -08:00
Dmitry Gozman c9ba49936f
feat(reporters): show retry #x when running a test (#11003) 2021-12-17 21:07:04 -08:00
Pavel Feldman 8f98074fc8
chore: add blink-diff third party library (#10984) 2021-12-17 15:53:37 -08:00
Dmitry Gozman b6aad54b9f
fix(test runner): test.setTimeout whould not break debugging (#11004)
We ignore test.setTimeout() when timeout is already zero for debugging.
2021-12-17 15:17:48 -08:00
Dmitry Gozman f5780be41b
fix(list reporter): make sure that duration suffix survives truncation (#11002) 2021-12-17 13:08:02 -08:00
Dmitry Gozman 93ad12978c
fix(test runner): disable expect, action and navigation timeouts on debug (#10958)
We disable these timeouts when test timeout is set to zero.
This covers PWDEBUG=1, --debug and manual `test.setTimeout(0)` scenarios.
2021-12-16 18:32:46 -08:00
Dmitry Gozman 192071d5bc
feat(test runner): save traces for beforeAll/afterAll hooks (#10950) 2021-12-15 16:06:10 -08:00
Dmitry Gozman 19b08332ce
feat(test runner): disable test timeout on page.pause() call (#10944) 2021-12-15 11:12:52 -08:00
Dmitry Gozman 0d54afab9c
feat(test runner): show beforeAll/afterAll hooks similar to tests (#10923)
Reporters now get notified about hooks start/end/steps.
2021-12-15 10:39:49 -08:00
Pavel Feldman f579f9c806
chore: parse tsx tests (#10917) 2021-12-14 19:25:07 -08:00
Dmitry Gozman 34b84841b0
chore(test runner): create TestResult instances lazily in dispatcher (#10921)
This prepares for beforeAll/afterAll hooks to be handled in the same way.
Since we do not know in advance whether a hook will run, we must create
TestResults lazily.
2021-12-14 14:10:56 -08:00
Dmitry Gozman 5c4ebdce54
fix(line reporter): clarify about retries when going over total counter (#10901) 2021-12-13 19:06:13 -08:00
Joel Einbinder c27491cd4d
feat(test-runner): shorten long output paths (#10523) 2021-12-13 10:56:03 -08:00
Joel Einbinder 7a02c52144
feat(test-runner): specific playwright types for expect (#10670) 2021-12-13 13:42:36 -05:00
Dmitry Gozman 308c7b4e32
docs: update test advanced guides (#10861)
Linking to the API reference, using better examples and newer docs.
2021-12-10 11:15:01 -08:00
Dmitry Gozman 897e41c6c1
docs: document TestOptions.video.size (#10827) 2021-12-09 07:38:58 -08:00
Pavel Feldman b5933db279
feat(tsconfig): respect baseUrl and paths from tsconfig (#10525) 2021-12-08 22:43:00 -08:00
Pavel Feldman 4d683cef7f
fix(html): render text attachments as text (#10778) 2021-12-08 08:51:44 -08:00
Pavel Feldman a08a41f6c9
chore: render annotations in html report (#10774) 2021-12-07 18:35:06 -08:00
Pavel Feldman feb4c62da1
fix(html): html reporter fixes (#10770) 2021-12-07 16:47:47 -08:00
Pavel Feldman 7765131a14
feat(acceptDownload): revert acceptDownload (#10709) 2021-12-06 09:25:24 -08:00
Pavel Feldman 518d67add5
feat(test.info): expose information on the currently running test (#10708) 2021-12-06 09:25:11 -08:00
Dmitry Gozman 98e2f40bb0
docs: replace TestCase.suite with TestCase.parent (#10687)
It is there by mistake.
2021-12-02 14:24:43 -08:00
Pavel Feldman 31e0a63fcd
feat(toBeChecked): allow passing checked: false (#10665) 2021-12-02 10:31:26 -08:00
Pavel Feldman b9731a904e
chore: add validations into check_deps (#10661) 2021-12-01 18:14:13 -08:00
Saransh Miglani f05252874a
chore: minor code rearrangement (#10650) 2021-12-01 09:18:16 -08:00
Yury Semikhatsky d66b7aab3b
feat(expext): toBeOK for APIResponse (#10596) 2021-11-30 18:12:19 -08:00
Dmitry Gozman 729da65eba
fix(test runner): allow multiple missing snapshots per test (#10621)
Instead of failing right away, continue test execution but mark
the test as failed.
2021-11-30 17:50:19 -08:00
Max Schmitt 3337920c76
docs: clarify webServer ipv4/ipv6 and baseURL protocol (#10610) 2021-11-30 20:01:28 +01:00
Max Schmitt 682d1f41c7
fix(test-runner): wrong test-runner options got determined (#10607)
Follow-up for #10507
2021-11-30 19:59:35 +01:00
Max Schmitt 9337aa3cdf
fix(test-runner): webServer port detection on Node.js 17 (#10538) 2021-11-29 19:36:35 +01:00
Joel Einbinder 15053d9b3b
fix(test-runner): apply default options to all browserTypes (#10507) 2021-11-29 12:21:15 -05:00
Max Schmitt 293c233a49
docs(test-runner): add webServer (#10531) 2021-11-29 18:01:14 +01:00
Joel Einbinder 20c0facfb9
fix(test runner): dont mangle test names with multiple dashes (#10447) 2021-11-24 19:36:38 -05:00
Pavel Feldman 5d19f16601
feat(esm): introduce experimental PW_EXPERIMENTAL_TS_ESM option (#10519) 2021-11-24 14:17:01 -08:00
Pavel Feldman 7eb3f76f49
feat(esm): allow running tests in type module projects (#10503) 2021-11-24 12:42:48 -08:00
Max Schmitt 85197e68c9
chore: support range requests in trace viewer http server (#10434) 2021-11-23 21:37:55 +01:00
Ross Wollman 854f321532
feat(api): add explicit async testInfo.attach (#10121)
feat(api): add explicit async testInfo.attach

We add an explicit async API for attaching file paths (and Buffers) to
tests that can be awaited to help users ensure they are attaching files
that actually exist at both the time of the invocation and later when
reporters (like the HTML Reporter) run and package up test artifacts.

This is intended to help surface attachment issues as soon as possible
so you aren't silently left with a missing attachment
minutes/days/months later when you go to debug a suddenly breaking test
expecting an attachment to be there.

NB: The current implemntation incurs an extra file copy compared to
manipulating the raw attachments array. If users encounter performance
issues because of this, we can consider an option parameter that uses
rename under the hood instead of copy. However, that would need to be
used with care if the file were to be accessed later in the test.
2021-11-23 09:30:53 -08:00
Dmitry Gozman e647f0420c
docs: add more references to TestInfo.retry (#10472) 2021-11-22 10:06:20 -08:00
Dmitry Gozman fde2f6a77f
docs: separate doc for test timeouts (#10448) 2021-11-19 17:06:46 -08:00
Dmitry Gozman 4eaeb3b59c
docs: explain that beforeAll/afterAll run again in the new worker process (#10446) 2021-11-19 13:47:30 -08:00
Dmitry Gozman 0302e759df
feat(test runner): allow top-level test.fixme similar to test.skip (#10250)
```js
test.fixme('my test name', () => {});
```
2021-11-19 11:40:40 -08:00
Dmitry Gozman d9f849fb14
feat(test runner): replace declare/define with "options" (#10293)
1. Fixtures defined in test.extend() can now have `{ option: true }` configuration that makes them overridable in the config. Options support all other properties of fixtures - value/function, scope, auto.
```
const test = base.extend<MyOptions>({
  foo: ['default', { option: true }],
});
```

2. test.declare() and project.define are removed.

3. project.use applies overrides to default option values and nothing else. Any test.extend() and test.use() calls take priority over config options.

Required user changes: if someone used to define fixture options with test.extend(), overriding them in config will stop working. The solution is to add `{ option: true }`.

```
// Old code
export const test = base.extend<{ myOption: number, myFixture: number }>({
  myOption: 123,
  myFixture: ({ myOption }, use) => use(2 * myOption),
});

// New code
export const test = base.extend<{ myOption: number, myFixture: number }>({
  myOption: [123, { option: true }],
  myFixture: ({ myOption }, use) => use(2 * myOption),
});
```
2021-11-18 15:45:52 -08:00
Dmitry Gozman 8f43f4c98f
feat(serial): better errors from beforeAll (#10419)
When beforeAll hook times out or fails with an exception, we now
close the context and show a nice error.
2021-11-18 14:36:55 -08:00
Dmitry Gozman bd93fc499f
fix(html reporter): show missing attachments as warnings (#10400) 2021-11-17 18:03:13 -08:00
Dmitry Gozman ce2c0c59a7
feat(expect): show expect timeout in the error message (#10388)
Makes it easier to understand that expect does indeed have a separate timeout.

```
    Error: expect(received).toHaveCount(expected) // deep equality

    Expected: 0
    Received: 1

    Call log:
      - expect.toHaveCount with timeout 500ms
      - waiting for selector "span"
      -   selector resolved to 1 element
      -   unexpected value "1"
      -   selector resolved to 1 element
      -   unexpected value "1"
      -   selector resolved to 1 element
      -   unexpected value "1"
```
2021-11-17 17:28:30 -08:00
Max Schmitt 0781d0303b
docs(python): enable web-first assertions (#10390) 2021-11-18 00:46:30 +01:00
Dmitry Gozman 638ebd6dd6
fix(test runner): do not validate fixtures in tests/hooks that are never run (#10328) 2021-11-15 13:17:26 -08:00
Dmitry Gozman 4bb123d4b7
fix(test runner): route more errors to reporter (#10263)
For example, top-level errors in files or global setup issues.
2021-11-12 06:47:41 -08:00
Andrey Lushnikov bd1ce399e3
fix(html-report): fix command to open HTML report (#10231) 2021-11-12 00:12:23 -08:00
Pavel Feldman 8dcd77270f
fix(sigint): remove sigint handler early (#10266) 2021-11-11 17:14:36 -08:00
Dmitry Gozman 7eec66d0f9
chore(test runner): route runner errors through Reporter.onError (#10257) 2021-11-11 16:48:08 -08:00
Dmitry Gozman f38f611478
chore: add npm run lint-tests (#10252) 2021-11-11 13:27:50 -08:00
Dmitry Gozman 4c93417e8a
fix(github reporter): handle global onError (#10256) 2021-11-11 13:25:38 -08:00
Dmitry Gozman 9622704a8a
fix(test runner): update TestInfo.duration before running afterEach hooks (#10228) 2021-11-10 16:02:27 -08:00
Andrey Lushnikov b2af576796
chore: cut v1.17 (#10203) 2021-11-09 17:56:26 -08:00
Pavel Feldman 7b64161a37
feat(test-runner): allow specifying fine-grained trace options (#10147) 2021-11-08 15:39:58 -08:00
Joel Einbinder 0cad0de3e3
fix(test runner): better error message when importing typescript from esmodule (#10061) 2021-11-08 16:25:40 -05:00
Dmitry Gozman 0a104bc500
docs: clarify that slow tests are about files (#10134) 2021-11-08 12:54:18 -08:00
Dmitry Gozman 3c1aaa5338
fix(trace): do not call tracing.stopChunk() twice (#10054) 2021-11-04 21:08:42 -07:00
Dmitry Gozman 3120f81629
fix(reporters): move Running X tests using Y workers to reporters (#10014) 2021-11-03 11:17:23 -07:00
Dmitry Gozman 9cebe60831
feat(reporters): augment non-stdio reporters with dot/line (#10003) 2021-11-03 08:25:16 -07:00
Andrey Lushnikov 62a01a41c6
feat: various docker integration improvements (#9988)
- shorter docker terminal message
- terminate testrunner if docker cannot be found
- use `-docker` suffix for snapshots / screenshots.
2021-11-02 13:58:26 -07:00
Pavel Feldman 6a30c90590
feat(trace-viewer): render wall time for each action (#9982) 2021-11-02 12:16:12 -07:00
Max Schmitt bedb817a00
docs(test-runner): worker fixtures only in before/after-All (#9967) 2021-11-02 16:51:41 +01:00
Nick Partridge a51ac39275
feat: add snapshotDir to set base snapshot directory (#9260) 2021-11-02 08:02:49 -07:00
Pavel Feldman 56ca3a18f5
feat(trace-viewer): show test name (#9957) 2021-11-01 21:23:35 -07:00
Pavel Feldman 3673776330
Revert "chore(test-runner): use test name as trace file name prefix (#9619)" (#9956)
This reverts commit 3c420a7cf1.
2021-11-01 20:27:41 -07:00
Pavel Feldman 85497c5509
feat(tracing): allow including source files in traces (#9946) 2021-11-01 19:57:29 -07:00
Pavel Feldman 2bfbf65b8d
fix(html): strip ansi escaping from stdio (#9944) 2021-11-01 16:39:54 -07:00
Pavel Feldman 9ac8829583
feat(html): bake report zip into the html report, allow opening from fs (#9939) 2021-11-01 16:14:52 -07:00
Pavel Feldman d79aae633c
feat(html): render the suite name before test title (#9909) 2021-11-01 10:53:42 -07:00
Dmitry Gozman 4f1027bdd0
feat(test runner): introduce TestInfo.parallelIndex (#9762)
This is a worker number between `0` and `workers - 1` that
does not change after worker process restart.
2021-11-01 10:37:34 -07:00
Max Schmitt 3c420a7cf1
chore(test-runner): use test name as trace file name prefix (#9619) 2021-11-01 18:15:19 +01:00
Dmitry Gozman 13844a5b0a
feat(html reporter): open test details page when running a single test (#9910) 2021-11-01 09:54:53 -07:00
Pavel Feldman d6adff7792
fix(html): include html into the reporter types (#9907) 2021-10-31 11:06:28 -07:00
Pavel Feldman 8991bbde33
feat(html): live filtering, opt-out from auto-open (#9889) 2021-10-29 16:24:08 -07:00
Dmitry Gozman 49337890d2
docs: improve documentation for assertions and test config (#9890) 2021-10-29 15:25:52 -07:00
Dmitry Gozman 227e3da62f
fix(test runner): do not reuse worker that did not teardown scopes (#9872)
Two bug fixes:
- Do not use the worker that is being shutdown for a new job.
- Report unhandled errors during "expected to fail" tests as
  fatal errors.
2021-10-29 13:36:12 -07:00
Pavel Feldman 2e4722d460
test: migrate to upstream fixtures (#9835) 2021-10-28 08:31:30 -07:00
Joel Einbinder c8addef03a
fix(monorepo): export package.json from every package (#9803) 2021-10-26 18:41:18 -04:00
Dmitry Gozman 22e4a0d580
fix(snapshots): --update-snapshots + retries should work (#9799) 2021-10-26 13:50:16 -07:00
Pavel Feldman 273122b761
chore: align internal test harness w/ @playwright/test (#9796) 2021-10-26 13:45:53 -07:00
Pavel Feldman 87c64b2c1c
chore: align client side instrumentations (#9771) 2021-10-26 11:13:35 -07:00
Pavel Feldman 5451808df1
chore: append sources to traces (#9736) 2021-10-25 18:56:57 -07:00
Dmitry Gozman 13ed1dee50
fix(test runner): do not mask uncaught error in beforeEach (#9764) 2021-10-25 14:17:27 -07:00
Pavel Feldman f08c22b467
fix(trace-viewer): show source files in local version (#9732) 2021-10-23 11:23:39 -07:00
Dmitry Gozman 23aa0be15b
docs: update afterEach docs with an example (#9727)
Also add a test for TestInfo.status in afterEach.
2021-10-22 16:32:22 -07:00
Joel Einbinder 940466f830
fix(npm): don't ship src in @playwright/test and ensure we ship cli.js in playwright-core 2021-10-22 16:15:57 -04:00
Joel Einbinder f2888395a6
fix: support even older node 12 (#9718) 2021-10-22 15:59:52 -04:00
Dmitry Gozman 193c79a685
feat(test runner): rewrite dispatcher to avoid unneded stalls (#9629)
In some circumstances, dispatcher was waiting for all exisitng jobs
to finish before scheduling a new one. This leads to unneded stalls.
Instead, we can schedule jobs right away, if we have a worker
available.
2021-10-22 11:10:37 -07:00
Max Schmitt e17dbe8d01
chore: pin expect package (#9713) 2021-10-22 08:07:33 -07:00
Pavel Feldman 225145fc3e
fix(expect): do not fail on navigated frames while polling (#9659) 2021-10-20 13:01:05 -07:00
Pavel Feldman b6a9a8a34a
Revert "chore: print global errors when running html report (#9657)" (#9661)
This reverts commit 68c9fce507.
2021-10-20 12:51:12 -07:00
Andrey Lushnikov 6b1767efbb
chore: cut v1.16.0 branch (#9656) 2021-10-20 12:44:32 -07:00
Pavel Feldman 68c9fce507
chore: print global errors when running html report (#9657) 2021-10-20 11:57:21 -07:00
Dmitry Gozman fb421e0a65
feat(github reporter): update docs, strip ansi escapes (#9640) 2021-10-20 07:56:03 -07:00
Pavel Feldman 4423de9996
chore: speed up snippet generation 50 times (#9638) 2021-10-19 21:10:14 -07:00
Andrey Lushnikov 983cfde4d4
feat: introduce docker integration for Playwright Test (#9599) 2021-10-19 16:10:24 -07:00
Pavel Feldman 9d03a85c30
chore: make web-first matchers work outside of pw tests (#9624) 2021-10-19 14:46:56 -07:00
Joel Einbinder adb5aa4544
fix(monorepo): support yarn2/pnp by specifying all deps and bins (#9620) 2021-10-19 14:49:47 -04:00
Joel Einbinder 53c866c0f2
fix(monorepo): explicitly list package.json exports instead of using glob patterns (#9584) 2021-10-19 12:28:02 -04:00
Dmitry Gozman 6d554a5e30
feat(reporter): expose more apis (#9603) 2021-10-19 08:38:04 -07:00
Yury Semikhatsky 6d727401bf
chore(fetch): rename ApiRequest* to APIRequest* (#9606) 2021-10-19 07:38:27 -07:00
Pavel Feldman bccd4c8906
feat(api): expose step location UI (#9605) 2021-10-18 22:14:01 -07:00
Pavel Feldman c06a6e1f63
fix(html): always highlight error code (#9604) 2021-10-18 21:37:19 -07:00
Pavel Feldman e37660b068
feat(api): expose step location (#9602) 2021-10-18 21:06:18 -07:00
Dmitry Gozman 4977edcaf3
fix(tracing): fix inconsistent calls of tracing.{start,stop} in fixtures (#9594)
Drive-by: fix error logging.
2021-10-18 21:05:59 -07:00
Pavel Feldman 99a2bd604d
chore: minor UI updates (#9590) 2021-10-18 13:34:02 -07:00
Pavel Feldman 432fb453e4
chore(html): only copy trace viewer for reports with traces (#9579) 2021-10-18 08:03:04 -07:00
Pavel Feldman 6afa85927e
chore(ui): redesign html report a bit (#9577) 2021-10-17 20:58:06 -07:00
Paul Biggar e473fc6a10
docs(test-runner): afterEach JSDoc description typo (#9542) 2021-10-16 12:36:07 +02:00
Feng Yu 0160c18f7a
docs: fix typo retried (#9562) 2021-10-15 19:24:03 -07:00
Pavel Feldman 99f3389b3b
feat(html): automatically use console reporter with html (#9559) 2021-10-15 19:18:56 -07:00
Pavel Feldman 9135847950
feat(ui): merge stdio in html report (#9560) 2021-10-15 16:15:06 -07:00
Pavel Feldman e31b96cc26
feat(tracing): make context.request appear in the trace (#9555) 2021-10-15 15:22:49 -07:00
Yury Semikhatsky 235cd10a43
fix(runner): clarify where test.use() can be called (#9486) 2021-10-15 12:03:26 -07:00
Pavel Feldman 458945821f
doc(html): document html reporter (#9528) 2021-10-15 08:15:30 -07:00
Pavel Feldman 5ea4ec2f7a
feat(html): open show html report when there are failures (#9526) 2021-10-14 21:09:41 -07:00
Yury Semikhatsky 4680ef46de
docs: clarify default retry behavior (#9525) 2021-10-14 19:28:47 -07:00
Dmitry Gozman c711fb35ad
fix(expect): do not rely on displayName (#9523)
Support for displayName was removed in Node 16.
Switching to Function.name instead.

Relevant V8 change: https://chromium-review.googlesource.com/c/v8/v8/+/2692189
2021-10-14 19:23:45 -07:00
Pavel Feldman 75cfe5d1f5
chore: start adding html runner e2e tests (#9518) 2021-10-14 15:48:05 -07:00
Pavel Feldman 584014f6fa
feat(html): unhide html reporter (#9512) 2021-10-14 11:17:35 -07:00
Joel Einbinder c8f875a193
chore: move test runner types into the playwright test package (#9472)
Co-authored-by: Max Schmitt <max@schmitt.mx>
2021-10-14 11:55:08 +02:00
Pavel Feldman bb77912aee
chore: don't include babel compiled files in webpack bundles (#9491) 2021-10-13 19:27:50 -07:00
Yury Semikhatsky e827bde1c2
fix(runner): skip global hooks in --list mode (#9480) 2021-10-13 14:18:15 -07:00
Joel Einbinder 2a0a44bc09
chore: move diff_match_patch into the test package (#9475) 2021-10-13 13:38:26 -07:00
Pavel Feldman cd99ad0da2
feat(trace): allow multiple traces in a single app, gc traces (#9478) 2021-10-13 13:31:54 -07:00
Pavel Feldman 8b1a887756
feat(html): link traces from html report (#9473) 2021-10-13 11:07:29 -07:00
Dmitry Gozman 64a3099655
chore(expect): simplify expect implementation (#9459) 2021-10-13 08:56:57 -07:00
Yury Semikhatsky 82ff85b106
fix(matchers): make isNot required in protocol (#9436) 2021-10-12 09:01:46 -07:00
Max Schmitt b1160ec239
chore(test-runner): make outputDir based on cwd instead of testDir (#9360) 2021-10-11 22:24:46 +02:00
Joel Einbinder d34b53a0d7
feat(test runner): allow comparing binary files to strings (#9315)
Co-authored-by: Max Schmitt <max@schmitt.mx>
2021-10-11 21:57:59 +02:00
Max Schmitt f0ff2a23d2
chore: add README's for packages (#9432) 2021-10-11 19:28:10 +02:00
Joel Einbinder c89d5a50dd
chore: migrate to monorepo (#9421) 2021-10-11 16:52:17 +02:00
Dmitry Gozman 167db03f05
feat(test-runner): export reporter api as @playwright/test/reporter (#7692) 2021-07-16 21:15:03 -07:00
Joel Einbinder 7629587914
fix(test-runner): work with .mjs files (#7373) 2021-06-29 15:28:41 -07:00
Joel Einbinder 0af1f4399d
fix(test-runner): fix default export breaking on installation tests (#7331) 2021-06-25 22:52:04 -07:00
Joel Einbinder 7caf05b24a
fix(playwright-test): have the proper default export (#7328)
There are 3 ways to import `@playwright/test` library in the modern Node.js ecosystem:
- Using `require`: works great, this patch doesn't change it
- Using `import` statement from `.mjs` file - we have wrong `default` for @playwright/test that should be a `test`. This is what test checks for
- Using `import test from '@playwright/test'` from `.ts` file - was broken because TypeScript thought it's a CJS module, whereas it's a ESM module in reality.

Also, typescript types import from `.d.ts` file was broken because we had no default export (`export *` syntax does not export default).
2021-06-25 15:29:22 -07:00
Pavel Feldman deec8a4adb
docs: make docs test-first (#7214) 2021-06-18 10:09:38 -07:00
Dmitry Gozman b625a04adc
types: move exported objects from index.d.ts to overrides.d.ts (#7152)
This way we generate these types right away, without duplicating them everywhere.
2021-06-15 15:06:18 -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
Dmitry Gozman 3de3a88930
feat(test): introduce npx playwright test (#6816) 2021-06-03 08:07:55 -07:00