Skip to content

Commit 36dfafe

Browse files
Add Playwright failure screenshot instructions (#38307)
1 parent 94fc3a9 commit 36dfafe

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

content/en/tests/setup/javascript.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,29 @@ For more information about custom measures, see the [Add Custom Measures Guide][
204204

205205
If the browser application being tested is instrumented using [Browser Monitoring][3], the Playwright test results and their generated RUM browser sessions and session replays are automatically linked. For more information, see the [Instrumenting your browser tests with RUM guide][4].
206206

207+
### Upload test failure screenshots
208+
209+
When enabled, Test Optimization uploads screenshots that Playwright captures when a test fails. View the screenshots in the {{< ui >}}Media{{< /ui >}} tab of the Test Optimization test details side panel. Use them to inspect browser state at the time of failure.
210+
211+
{{< img src="continuous_integration/tests/setup/playwright-failure-screenshot-media-tab.png" alt="A Playwright failure screenshot displayed in the Media tab of the Test Optimization test details side panel." style="width:100%;" >}}
212+
213+
Use [`dd-trace` v5.116.0 or later][5] on the v5 release line, or [`dd-trace` v6.5.0 or later][6] on the v6 release line.
214+
215+
To enable screenshot uploads, set the `DD_TEST_FAILURE_SCREENSHOTS_ENABLED` environment variable to `1`. In your Playwright configuration, set [`screenshot`][7] under `use` to one of the following values:
216+
217+
- `'on'`: Capture screenshot after each test.
218+
- `'only-on-failure'`: Capture screenshot after each test failure.
219+
- `'on-first-failure'`: Capture screenshot after each test's first failure.
220+
221+
**Note**: If you use `'on'`, Test Optimization only uploads screenshots from failed tests.
222+
207223
[1]: /tracing/trace_collection/custom_instrumentation/nodejs?tab=locally#adding-tags
208224
[2]: /tests/guides/add_custom_measures/?tab=javascripttypescript
209225
[3]: /real_user_monitoring/application_monitoring/browser/setup/
210226
[4]: /continuous_integration/guides/rum_integration/
227+
[5]: https://github.com/DataDog/dd-trace-js/releases/tag/v5.116.0
228+
[6]: https://github.com/DataDog/dd-trace-js/releases/tag/v6.5.0
229+
[7]: https://playwright.dev/docs/api/class-testoptions#test-options-screenshot
211230
{{% /tab %}}
212231

213232
{{% tab "Cucumber" %}}
@@ -408,7 +427,9 @@ When enabled, Test Optimization uploads screenshots that Cypress captures when a
408427

409428
{{< img src="continuous_integration/tests/setup/cypress-failure-screenshot-media-tab.png" alt="A Cypress failure screenshot displayed in the Media tab of the Test Optimization test details side panel." style="width:100%;" >}}
410429

411-
To enable screenshot uploads, set the `DD_TEST_FAILURE_SCREENSHOTS_ENABLED` environment variable to `1`. In your Cypress configuration, make sure [`screenshotOnRunFailure`][8] is set to `true` (the default).
430+
Use [`dd-trace` v5.112.0 or later][8] on the v5 release line, or [`dd-trace` v6.1.0 or later][9] on the v6 release line.
431+
432+
To enable screenshot uploads, set the `DD_TEST_FAILURE_SCREENSHOTS_ENABLED` environment variable to `1`. In your Cypress configuration, make sure [`screenshotOnRunFailure`][10] is set to `true` (the default).
412433

413434
[1]: https://docs.cypress.io/guides/tooling/plugins-guide#Using-a-plugin
414435
[2]: https://docs.cypress.io/api/plugins/after-run-api
@@ -417,7 +438,9 @@ To enable screenshot uploads, set the `DD_TEST_FAILURE_SCREENSHOTS_ENABLED` envi
417438
[5]: /tests/guides/add_custom_measures/?tab=javascripttypescript
418439
[6]: /real_user_monitoring/application_monitoring/browser/setup/
419440
[7]: /continuous_integration/guides/rum_integration/
420-
[8]: https://docs.cypress.io/app/references/configuration#Screenshots
441+
[8]: https://github.com/DataDog/dd-trace-js/releases/tag/v5.112.0
442+
[9]: https://github.com/DataDog/dd-trace-js/releases/tag/v6.1.0
443+
[10]: https://docs.cypress.io/app/references/configuration#Screenshots
421444
{{% /tab %}}
422445

423446
{{% tab "Vitest" %}}
436 KB
Loading

0 commit comments

Comments
 (0)