playwright/tests/playwright-test
오소현 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
..
__screenshots__/playwright.artifacts.spec.ts feat: allow options in automatic screenshots (#19143) 2022-12-07 08:45:33 -08:00
assets fix(ui): print the web server output in the ui mode (#31824) 2024-07-23 16:52:32 -07:00
stable-test-runner chore: roll stable test runner to 1.47 beta (#32469) 2024-09-05 13:44:22 +02:00
access-data.spec.ts test: remove magic headers in ttest (#20867) 2023-02-14 19:20:56 -08:00
babel.spec.ts chore: allow marking scripts as external for transform (#23449) 2023-06-01 20:28:49 -07:00
basic.spec.ts chore: rewrite worker main through TestInfoImpl._runAsStage (#29644) 2024-03-04 19:36:58 -08:00
clear-cache.spec.ts chore: implement clear-cache through plugins (#32471) 2024-09-05 13:50:16 -07:00
command-line-filter.spec.ts chore: remove unnecessary args in ttest (#21012) 2023-02-18 13:08:17 -08:00
config.spec.ts feat: TestProject.ignoreSnapshots (#30466) 2024-04-22 16:16:38 -07:00
decorators.spec.ts chore: allow ts decorators (#22080) 2023-03-29 20:43:08 -07:00
deps.spec.ts chore(test runner): do not produce some of the fake skipped test results (#27730) 2023-10-20 17:01:46 -07:00
esm.spec.ts feat(test runner): --tsconfig cli option (#31932) 2024-08-06 06:55:15 -07:00
exit-code.spec.ts feat: implement flag to fail flaky tests (#30618) 2024-05-15 09:10:10 -07:00
expect-configure.spec.ts chore: populate matcherResult in web assertions (#27133) 2023-09-16 14:24:10 -07:00
expect-poll.spec.ts fix(expect): respect custom message in expect.poll (#32603) 2024-09-16 00:10:06 -07:00
expect-soft.spec.ts docs: do not call custom expect message an "error message" (#29390) 2024-02-06 12:12:45 -08:00
expect-to-pass.spec.ts feat: Support intervals arg for toPass (#30037) 2024-03-29 10:17:29 -07:00
expect.spec.ts feat(test runner): make expect.extend immutable (#32366) 2024-09-12 19:56:38 +02:00
find-related-tests.spec.ts chore: make find-related-test-files work through plugins (#32465) 2024-09-05 06:52:11 -07:00
fixture-errors.spec.ts feat: allow boxing and titling fixtures, simulate context fixture deps (#31423) 2024-06-24 21:43:43 -07:00
fixtures.spec.ts fix(test runner): make sure auto worker fixtures run before auto test fixtures (#27131) 2023-09-15 14:51:31 -07:00
gitignore.spec.ts feat(config): respectGitIgnore option (#30972) 2024-05-23 12:05:02 -07:00
global-setup.spec.ts chore: get rid of ConfigInWorker, use FullConfig instead (#30517) 2024-04-24 14:14:05 -07:00
golden.spec.ts fix(toHaveScreenshot): sanitize attachment names and paths (#31712) 2024-07-17 07:08:43 -07:00
hooks.spec.ts fix(test runner): timeout in fixture teardown should not prevent other slots (#32157) 2024-08-16 04:25:00 -07:00
list-files.spec.ts chore: implement server-based list files (#29633) 2024-02-23 08:29:44 -08:00
list-mode.spec.ts Revert "fix: respect .only in --list mode" (#28770) 2023-12-22 11:03:30 -08:00
loader.spec.ts fix(test runner): do not revert the transform (#31930) 2024-07-31 13:17:09 -07:00
match-grep.spec.ts fix(ui): when --grep is used, UI should only show selected tests (#31815) 2024-07-23 15:29:08 +02:00
max-failures.spec.ts fix(test-runner): do not consider retries for maxFailures (#32533) 2024-09-11 20:35:26 +02:00
only-changed.spec.ts chore(test runner): rebase watch mode onto TestServerConnection (#32156) 2024-09-03 15:15:44 +02:00
override-timeout.spec.ts test: remove magic headers in ttest (#20867) 2023-02-14 19:20:56 -08:00
playwright-test-fixtures.ts chore: implement clear-cache through plugins (#32471) 2024-09-05 13:50:16 -07:00
playwright.artifacts.spec.ts Revert "feat(tracing): add .pwtrace to trace file extension" (#32648) 2024-09-17 15:32:30 +02:00
playwright.config.spec.ts test: remove magic headers in ttest (#20867) 2023-02-14 19:20:56 -08:00
playwright.config.ts chore: roll expect and move it to third party (#32458) 2024-09-09 13:12:20 -07:00
playwright.connect.spec.ts Revert "feat(trace): record trace upon browser closure (#31563)" (#31677) 2024-07-15 01:08:51 -07:00
playwright.ct-build.spec.ts fix(ct): allow importing components from node_modules (#30493) 2024-04-24 12:32:28 -07:00
playwright.ct-dev-server.spec.ts chore: make dev server only use public config (#32441) 2024-09-04 01:29:55 -07:00
playwright.ct-react.spec.ts test: unflake should pass "key" attribute from JSX in variable (#31141) 2024-06-04 17:57:57 +02:00
playwright.fetch.spec.ts chore: hint at unroute for handle errors (#30949) 2024-05-22 08:54:19 -07:00
playwright.reuse.browser.spec.ts fix(connect): annotate internal api calls correctly (#31715) 2024-07-17 09:00:47 +02:00
playwright.reuse.spec.ts Revert "feat(tracing): add .pwtrace to trace file extension" (#32648) 2024-09-17 15:32:30 +02:00
playwright.spec.ts fix(test runner): do not use @babel/plugin-transform-dynamic-import (#31285) 2024-06-13 06:18:44 -07:00
playwright.trace.spec.ts Revert "feat(tracing): add .pwtrace to trace file extension" (#32648) 2024-09-17 15:32:30 +02:00
playwright.unhandled.spec.ts fix(test runner): properly handle uncaught errors in test.fail() (#27734) 2023-10-23 09:14:31 -07:00
repeat-each.spec.ts test: remove magic headers in ttest (#20867) 2023-02-14 19:20:56 -08:00
reporter-attachment.spec.ts Revert "feat(tracing): add .pwtrace to trace file extension" (#32648) 2024-09-17 15:32:30 +02:00
reporter-base.spec.ts test: relax "should print if globalTimeout is reached" expectation (#30558) 2024-04-25 18:40:58 -07:00
reporter-blob.spec.ts test: fix project filter test (#32525) 2024-09-09 14:00:51 -07:00
reporter-dot.spec.ts chore: run more reporter tests through blob report, some fixes (#23765) 2023-06-16 21:30:55 -07:00
reporter-github.spec.ts chore: run more reporter tests through blob report, some fixes (#23765) 2023-06-16 21:30:55 -07:00
reporter-html.spec.ts feat(html reporter): open html attachments in new tab (#32389) 2024-09-02 08:35:53 +02:00
reporter-json.spec.ts feat(reporters): align and document environment variables (#30912) 2024-05-21 10:46:52 -07:00
reporter-junit.spec.ts chore: add common env vars for junit and json reporters (#30611) 2024-05-01 10:16:49 -07:00
reporter-line.spec.ts chore: trim multiline step titles to first line (#31269) 2024-06-12 08:24:12 -07:00
reporter-list.spec.ts fix(list reporter): print step ends in non-TTY mode (#31703) 2024-07-17 13:36:37 +02:00
reporter-markdown.spec.ts fix(merge): normalize path separators when merging across platforms (#28227) 2023-11-27 12:43:56 -08:00
reporter-onend.spec.ts feat(onEnd): allow overriding the exit code (#27010) 2023-09-12 13:37:30 -07:00
reporter.spec.ts test: unflake "should work with custom reporter" (#30526) 2024-04-24 20:03:39 -07:00
resolver.spec.ts fix(test runner): allow directory imports with path mapping (#32491) 2024-09-09 14:01:20 -07:00
retry.spec.ts fix(reporters): properly determine flaky status for serial mode (#30529) 2024-04-25 13:39:14 -07:00
runner.spec.ts Revert "fix: shut down workers before reporter.onEnd (#30329)" (#30551) 2024-04-25 14:21:54 -07:00
shard.spec.ts Fix various typos (Fixes #27396) (#27391) 2023-10-04 19:56:42 -07:00
snapshot-path-template.spec.ts test: remove magic headers in ttest (#20867) 2023-02-14 19:20:56 -08:00
stdio.spec.ts feat(test runner): do not mock tty in the worker process (#30107) 2024-03-25 15:31:58 -07:00
test-extend.spec.ts chore: composed->merge (#27555) 2023-10-11 13:56:27 -07:00
test-grep.spec.ts Fix various typos (Fixes #27396) (#27391) 2023-10-04 19:56:42 -07:00
test-ignore.spec.ts test: remove magic headers in ttest (#20867) 2023-02-14 19:20:56 -08:00
test-info.spec.ts test: remove magic headers in ttest (#20867) 2023-02-14 19:20:56 -08:00
test-modifiers.spec.ts fix(runner): do not run beforeEach hooks upon skip modifier (#31426) 2024-06-25 10:47:37 -07:00
test-output-dir.spec.ts chore: trim file names longer than 60 chars (was 100) (#29725) 2024-03-18 12:53:15 -07:00
test-parallel.spec.ts test: remove magic headers in ttest (#20867) 2023-02-14 19:20:56 -08:00
test-serial.spec.ts fix(reporters): properly determine flaky status for serial mode (#30529) 2024-04-25 13:39:14 -07:00
test-server.spec.ts chore: implement clear-cache through plugins (#32471) 2024-09-05 13:50:16 -07:00
test-step.spec.ts feat(test runner): allow to pass arbitrary location to test.step (#32504) 2024-09-17 08:11:21 -07:00
test-tag.spec.ts Revert "chore: enforce tags format via typescript types (#32384)" (#32431) 2024-09-03 10:07:08 -07:00
test-use.spec.ts test: remove magic headers in ttest (#20867) 2023-02-14 19:20:56 -08:00
timeout.spec.ts fix(test runner): timeout in fixture teardown should not prevent other slots (#32157) 2024-08-16 04:25:00 -07:00
to-have-screenshot.spec.ts fix(toHaveScreenshot): attach "expected" when writing a missing expectation (#31745) 2024-07-18 02:42:44 -07:00
types-2.spec.ts feat(test runner): tags/annotations (#29248) 2024-02-07 16:31:25 -08:00
types.spec.ts fix(types): revert type changes made to support TS 5.5 (#32066) 2024-08-08 05:21:48 -07:00
ui-mode-fixtures.ts fix(tracing): speed up trace recording (#30946) 2024-05-22 15:19:32 -07:00
ui-mode-test-annotations.spec.ts test: ui mode annotations (#31965) 2024-08-01 14:47:50 -07:00
ui-mode-test-attachments.spec.ts feat(ui mode): linkify attachment names and content (#31960) 2024-08-01 09:27:45 -07:00
ui-mode-test-ct.spec.ts chore: automatically detect the dev server (#29176) 2024-01-25 11:46:47 -08:00
ui-mode-test-filters.spec.ts chore(ui): add test expectation that doesn't immediately pass on blank tree (#31850) 2024-07-25 12:21:24 +02:00
ui-mode-test-network-tab.spec.ts feat(ui-mode): display list of query params in request tab (#32443) 2024-09-04 07:54:44 -07:00
ui-mode-test-output.spec.ts feat(ui mode): introduce Testing Options and Settings (#31841) 2024-07-25 11:23:43 -07:00
ui-mode-test-progress.spec.ts fix(test runner): make TestTracing responsible for trace management (#29181) 2024-01-26 15:52:25 -08:00
ui-mode-test-run.spec.ts chore(ui): update to react 18 (#32079) 2024-08-12 13:50:11 +02:00
ui-mode-test-screencast.spec.ts test: unflake various tests (#32014) 2024-08-05 08:29:13 -07:00
ui-mode-test-setup.spec.ts fix(ui): respect --output param (#32351) 2024-08-30 08:29:49 +02:00
ui-mode-test-shortcut.spec.ts chore: address UI Mode keyboard shortcut feedback (#30088) 2024-03-25 19:48:20 +01:00
ui-mode-test-source.spec.ts fix(dupe): render dupe test error indicator (#32303) 2024-08-23 14:33:37 -07:00
ui-mode-test-tree.spec.ts fix: rebuild project tree from scratch when listing tests (#30407) 2024-04-18 16:49:07 -07:00
ui-mode-test-update.spec.ts feat(ui mode): ui updates (#31894) 2024-07-29 07:32:13 -07:00
ui-mode-test-watch.spec.ts fix(ui): added test in watched file should be run (#31842) 2024-07-30 14:17:41 +02:00
ui-mode-trace.spec.ts fix(toHaveScreenshot): attach "expected" when writing a missing expectation (#31745) 2024-07-18 02:42:44 -07:00
watch.spec.ts feat(watch mode): buffer mode (#32631) 2024-09-17 08:45:44 +02:00
web-server.spec.ts fix(HEAD): revert GET->HEAD migration, net-effect was negative (#29738) 2024-02-29 09:02:05 -08:00
worker-index.spec.ts test: remove magic headers in ttest (#20867) 2023-02-14 19:20:56 -08:00