How do I use soft assertions and custom error messages in Playwright Test to update test plan status in a pipeline?


Updating Test Plan Status in a Pipeline with Soft Assertions and Custom Error Messages

To update test plan status when running @playwright/test on a pipeline, you can use soft assertions and custom error messages. Soft assertions, introduced in Playwright Test v1.19, allow you to make checks that won't stop the test when they fail but will mark the test as failed.

Here's an example of using soft assertions with custom error messages:

import { test, expect } from '@playwright/test';

test('Update test plan status', async ({ page }) => {
  await page.goto('https://ray.run/');
  // Use soft assertions with custom error messages
  await expect.soft(page.locator('#status')).toHaveText('Success', 'Test plan status: Success');

In this example, the test checks if an element with the id status has the text "Success". If the check fails, the test will be marked as failed, and the custom error message "Test plan status: Success" will be displayed.

By using soft assertions and custom error messages, you can provide meaningful information about the impact of failed checks on your overall testing strategy.

Additionally, you can use the Playwright Trace Viewer (available online at https://trace.playwright.dev) to analyze your tests' performance and identify bottlenecks or issues. Just drag-and-drop your trace.zip file to inspect its contents.

In summary, using soft assertions and custom error messages in @playwright/test, along with tools like Trace Viewer, helps you create a robust and reliable testing strategy across different platforms and configurations.

Thank you!
Was this helpful?
Still have questions?

If you still have questions, please ask a question and I will try to answer it.

AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.