3863 Commits

Author SHA1 Message Date
오소현
8761dafc73
feat(test runner): allow to pass arbitrary location to test.step (#32504)
Fixes https://github.com/microsoft/playwright/issues/30160

### Description:
This pull request introduces the ability to specify custom locations for
test steps in Playwright. By enabling the provision of arbitrary
locations to the test.step method, it resolves the limitation where
helper methods obfuscate the original call site, providing more accurate
and meaningful location data in test reports.

### Motivation:
To enhance the utility and clarity of test reports in Playwright.
Specifically, it addresses the need to trace test steps back to their
precise location in the code, which is especially important when steps
are abstracted in helper functions. This feature is crucial for
maintaining accurate documentation and facilitating debugging processes.

### Changes:
Added functionality to pass a custom location object to test.step.

### Expected Outcome:
This PR is expected to significantly improve the precision and
usefulness of diagnostic data in test reports by allowing specific
locations within helper functions to be accurately documented. It
facilitates better tracking of test executions and simplifies the
debugging process, making it easier for developers to understand and
address issues within complex tests.

### References:
Closes https://github.com/microsoft/playwright/issues/30160 -
"[Feature]: allow to pass arbitrary location to test.step"

**Code Check**
I conducted tests on this new feature by integrating it into some
existing test codes, and it worked well. I will attach the code used for
testing and a screenshot showing the successful outcome.

<details>
<summary>toggle dropdown</summary>
<div markdown="1">

```
import type { Location } from '../../../packages/playwright/types/testReporter'
...
test('should respect the back button', async ({ page }) => {
    await page.locator('.todo-list li .toggle').nth(1).check();
    await checkNumberOfCompletedTodosInLocalStorage(page, 1);
...
    await test.step('Showing active items', async () => {
      await page.getByRole('link', { name: 'Active' }).click();
    }, {location});
```

<img width="1109" alt="image"
src="https://github.com/user-attachments/assets/359feafa-0949-4c71-9426-46debef21bdd">
</div>
</details>
2024-09-17 08:11:21 -07:00
Simon Knott
751b939d3a
feat(fetch): record timings (#32613)
Related to https://github.com/microsoft/playwright/issues/19621

Adds some instrumentation to collect timings for `APIRequestContext`
requests and adds them to the HAR trace. Doesn't yet expose them via an
API, but makes our `Duration` field in the trace viewer show a nice
duration:

<img width="1392" alt="Screenshot 2024-09-14 at 11 46 04"
src="https://github.com/user-attachments/assets/8020382d-9494-4634-9cfd-22b6f4a1d770">


I'm gonna add it to our API in a separate PR.

---------

Signed-off-by: Simon Knott <info@simonknott.de>
Co-authored-by: Dmitry Gozman <dgozman@gmail.com>
2024-09-17 16:11:21 +02:00
Simon Knott
f6219e6e79
Revert "feat(tracing): add .pwtrace to trace file extension" (#32648)
Reverts microsoft/playwright#32581
Relates
https://github.com/microsoft/playwright/issues/32226#issuecomment-2351164727
2024-09-17 15:32:30 +02:00
Simon Knott
ec2ae1ed2d
feat(watch mode): buffer mode (#32631)
Closes https://github.com/microsoft/playwright/issues/32578.

Adds a buffer mode that can be toggled by pressing <kbd>b</kbd>. When
engaged, changed test files are collected and shown on screen. The test
run is then kicked off by pressing <kbd>Enter</kbd>.

This changes the signal to start a test run from <kbd>Cmd+s</kbd> to a
<kbd>Enter</kbd> press in the test terminal. It should help users with
auto-save and make it easier to run on long-running tests. It feels very
similar to running `npx playwright test`, but without having to write a
filter.



https://github.com/user-attachments/assets/71e16139-9427-4e90-b523-8d218f09ed9d
2024-09-17 08:45:44 +02:00
Simon Knott
b0f15b320f
fix(recorder): reattach toolbar if it was unmounted by framework hydration (#32637)
Closes https://github.com/microsoft/playwright/issues/32632. A side
effect of Remix's hydration implementation is that it throws away the
entire DOM. This is broadly discussed in
https://github.com/remix-run/remix/issues/4822 - there might be a fix in
coming React versions, but who knows.
Besides breaking browser extensions, this also deletes our toolbar!
This PR fixes it by periodically checking in on `x-pw-glass`, and
remounting it if it was unmounted. Hacky but effective!
2024-09-17 08:37:49 +02:00
Pavel Feldman
6dbde62a6b
chore: simplify signal handling while recording (#32624) 2024-09-16 14:39:36 -07:00
Max Schmitt
21d162c945
feat(client-certificates): add support for proxies (#32611)
Fixes https://github.com/microsoft/playwright/issues/32370
2024-09-16 17:57:33 +02:00
Dmitry Gozman
268357238a
fix(expect): respect custom message in expect.poll (#32603)
Fixes #32582.
2024-09-16 00:10:06 -07:00
Simon Knott
aeb4d182f7
feat(tracing): add .pwtrace to trace file extension (#32581)
Closes https://github.com/microsoft/playwright/issues/32226

I've updated every mention of `.trace.zip` except for the release notes.
2024-09-14 10:17:07 +02:00
Yury Semikhatsky
34876e9291
chore: cookies in intercepted bidi requests (#32623) 2024-09-13 18:29:35 -07:00
Matthew Jee
f2a974b045
feat(api): add method to force garbage collection (#32383) 2024-09-13 23:09:36 +02:00
Max Schmitt
79cba7d704
chore: introduce option overrides on context/browser (#32606) 2024-09-13 17:34:34 +02:00
Simon Knott
9bb1c86f93
feat(test runner): don't run tests on --watch start (#32583)
Closes https://github.com/microsoft/playwright/issues/32580.
2024-09-13 17:24:38 +02:00
Simon Knott
48c7fb6b06
feat(library): accept FormData in fetch (#32602)
Closes https://github.com/microsoft/playwright/issues/26520 by accepting
`FormData`, which became stable in Node.js in v21.
2024-09-13 13:21:02 +02:00
Pavel Feldman
d051495c7a
chore: perform double click while recording (#32576) 2024-09-12 11:40:44 -07:00
Max Schmitt
8e82f53ceb
test: unskip various proxy tests (#32595)
Unskipping of various tests and revert the rest of
https://github.com/microsoft/playwright/pull/6350 since the upstream bug
has been fixed.
2024-09-12 20:31:22 +02:00
Simon Knott
ef4be6afff
feat(test runner): make expect.extend immutable (#32366)
Changes `expect.extend` behaviour so that it doesn't mutate the global
instance and behaves closer to what users expect. This is formally a
breaking change, and I had to remove a test that asserts the breaking
behaviour.

TODO:
- [x] decide wether this is a separate method or a flag for
`expect.extend`
- [x] figure out if we need to change docs
2024-09-12 19:56:38 +02:00
Yury Semikhatsky
d1926e2f9b
chore: do not store project name in expectations (#32575) 2024-09-11 15:15:10 -07:00
Yury Semikhatsky
678c454fea
test: update bidi expectations from recent run (#32574) 2024-09-11 14:59:28 -07:00
Yury Semikhatsky
fd1f32556b
chore: run all tests with bidi by default (#32572)
Only use expectation files on CI to save resources
2024-09-11 14:24:32 -07:00
Yury Semikhatsky
a8103abee6
chore: incremental bidi expectation update, ff expectations (#32570)
* Do not override expectations for the tests that didn't run or already
had expectations
* Sort expectations alphabetically
* Add firefox expectations
2024-09-11 13:33:25 -07:00
Max Schmitt
7458c3292c
fix(test-runner): do not consider retries for maxFailures (#32533)
Fixes https://github.com/microsoft/playwright/issues/26350
2024-09-11 20:35:26 +02:00
Yury Semikhatsky
1f0514536e
chore: add bidi test expectations in separate file (#32549)
Based on the expectations the tests that are expected to timeout or fail
will be skipped to save resources. The expectations can be manually
updated when corresponding feature is fixed.
2024-09-11 08:28:29 -07:00
Dmitry Gozman
7335fa602c
fix(trace viewer): do not show multiple action points in iframes (#32537)
When action has an input target, we assume there is a target element in
one of the frames and show action point in its center.

Fixes #32453.
2024-09-11 03:04:03 -07:00
Rui Figueira
f8562e4ca7
chore: improve error message when Array.toJSON misbehaves (#32508)
Fixes: #32507
2024-09-10 04:14:24 -07:00
Max Schmitt
9fa06be49e
fix(ct): throw error if inline component is getting mounted (#32531)
What was happening?
- When we use CT, we go over the test files, look at the imports using
`tsxTransform.ts` and store them inside a map, these we feed into the
import registry which we build using Vite and have access inside the
browser
- In case of an inline component in the same file as where the test file
is, this is not happening.
- jsx-runtime via babel kicks in, transforms every JSX component in
something like that:

```
{
  __pw_type: 'jsx',
  type: [Function: MyInlineComponent],
  props: { value: 'Max' },
  key: undefined
}
```

this then gets passed into `wrapObject` which maps any function from the
Node.js side into expose function calls so they work inside the browser.
The assumption for `wrapObject` was to do it mostly for callbacks. So it
does for `type` - which is actually our component. We then pass this to
the React render function, which calls back the exposed function but we
never return anything, so it mounts `undefined`.

---

While there have been experiments from certain vendors to get the
'client only' code inside a server side file, we should throw for now to
not confuse users. We might revisit this in the future since Babel / TSX
doesn't support it outside of the box.

Fixes https://github.com/microsoft/playwright/issues/32167
2024-09-10 11:15:20 +02:00
Yury Semikhatsky
c8a72d63ad
chore: run bidi firefox tests on ci (#32527) 2024-09-09 17:22:19 -07:00
Pavel Feldman
6d5889a52c
chore: revert the matcherResult in API (#32524) 2024-09-09 16:44:32 -07:00
Dmitry Gozman
ae118674b8
fix(test runner): allow directory imports with path mapping (#32491)
We now hopefully align with `moduleResolution: bundler` tsconfig option,
allowing directory imports in every scenario, and allowing proper module
imports when not going through the type mapping.

This regressed in #32078. Fixes #32480, fixes #31811.
2024-09-09 14:01:20 -07:00
Dmitry Gozman
6bb005db85
fix(test runner): improve error message when not able to parse tsconfig (#32526) 2024-09-09 14:01:02 -07:00
Dmitry Gozman
e6c5b6054d
test: fix project filter test (#32525)
It was erroneously passing projects separate by comma, which never
worked.
2024-09-09 14:00:51 -07:00
Pavel Feldman
9a313eecc9
chore: roll expect and move it to third party (#32458) 2024-09-09 13:12:20 -07:00
Simon Knott
cc9c4cdd9a
chore: fix flaky screenshot test (#32517)
In this test, the trace recording goes super fast. Sometimes, this means
that the recording is finished before the screen recorder got a chance
to take a screenshot. If that happens, the tests fail because we never
show a screenshot.
This PR fixes the flakiness by delaying the trace recording so that
there's always a screenshot taken.
2024-09-09 14:00:38 +02:00
Max Schmitt
ae02331d00
test: fix stress tests bots (#32513) 2024-09-09 12:52:40 +02:00
Max Schmitt
718bd9b35f
devops: run BiDi tests (#32493) 2024-09-07 09:16:42 +02:00
Yury Semikhatsky
a113553f14
test: allow running oopif test without newBrowserCDPSession (#32496) 2024-09-06 13:49:37 -07:00
Yury Semikhatsky
df2bc2d0dc
test: worker interception for existing workers (#32494)
Failing test for https://github.com/microsoft/playwright/issues/32355
2024-09-06 13:17:49 -07:00
Yury Semikhatsky
d85527e9f6
test: some tests for expected API behavior (#32495)
Adding some tests discussed in
https://github.com/microsoft/playwright/pull/32434
2024-09-06 13:13:44 -07:00
Dmitry Gozman
1402dee9e6
Revert "fix(test runner): align with typescript behaviour for resolving index.js and package.json through path mapping (#32078)" (#32492)
This reverts commit effb1ae2349aeef1c0bfb0b6cd886b9b4b32c8e5.

This broke path mapping into directories in ESM mode. References #32480.
2024-09-06 12:08:10 -07:00
Simon Knott
3fe1263643
feat(trace viewer): show Screenshot instead of Snapshot (#32248)
Closes https://github.com/microsoft/playwright/issues/23964.

Trace snapshots are a best-effort snapshots of the browser DOM, but we
can't guarantee them to be exactly what the browser showed. One example
of this is `canvas` elements, where you just can't see their contents.
That makes snapshots useful, but not perfect.

For those cases where the snapshot doesn't show everything, this PR
introduces a new setting to show a screenshot instead. You won't be able
to scroll or inspect the DOM or select a locator anymore. But if the
snapshot was missing something, or displaying something wrong, you can
now check the screenshot instead.
2024-09-06 16:24:33 +02:00
Max Schmitt
ed303208b3
test: update to android-35 SDK (Android 15) (#32430) 2024-09-06 14:27:56 +02:00
Simon Knott
0e3f4736cc
fix(test runner): always show all projects in selection (#32450)
Follow-up to
https://github.com/microsoft/playwright/pull/32156#discussion_r1741628770,
alternative solution to
https://github.com/microsoft/playwright/pull/32425.

Ensures we always show all projects in the watch mode project selector
by performing the initial `listTests` without any filters, and using its
result for the project selector.
2024-09-06 11:35:20 +02:00
Pavel Feldman
a52eb0c9a0
chore: expose matcherResult on TestError (#32455) 2024-09-05 21:36:51 -07:00
Yury Semikhatsky
f0e13164d7
chore: split firefox and chromium bidi implementations (#32478) 2024-09-05 18:31:56 -07:00
Yury Semikhatsky
752b171a13
chore: support bidi connection to chromium (#32474) 2024-09-05 14:56:07 -07:00
Dmitry Gozman
1ba3db6864
chore: implement clear-cache through plugins (#32471)
Also switches it to task runner.
2024-09-05 13:50:16 -07:00
Dmitry Gozman
d4c77ce260
chore: make find-related-test-files work through plugins (#32465)
Also switches it to the task runner.
2024-09-05 06:52:11 -07:00
Simon Knott
29f1541b14
chore: roll stable test runner to 1.47 beta (#32469) 2024-09-05 13:44:22 +02:00
Dmitry Gozman
91012833c6
chore: move 'dev-server' extensibility point to plugin (#32448)
Instead of plumbing it through a custom unspecified config field, make
it a part of plugin interface.

Additionally, use task runner for starting/stopping dev server.
2024-09-05 02:22:27 -07:00
Yury Semikhatsky
9a2c60a77c
chore: identify largest gaps in Bidi API (#32434)
This pull request introduces initial support for the WebDriver BiDi
protocol in Playwright. The primary goal of this PR is not to fully
implement BiDi but to experiment with the current state of the
specification and its implementation. We aim to identify the biggest
gaps and challenges that need to be addressed before considering BiDi as
the main protocol for Playwright.
2024-09-04 11:36:52 -07:00