← Back to library
Playwrightassertionsadvancedv1.30+

Soft assertions — collect all failures

Use expect.soft() to continue the test after a failure and report all assertion errors together.

1test('profile page shows all user fields correctly', async ({ page }) => {
2  await page.goto('/profile');
3
4  // expect.soft() records the failure but does NOT stop execution —
5  // all soft failures are reported together at the end of the test
6  await expect.soft(page.getByTestId('username')).toHaveText('Alice');
7  await expect.soft(page.getByTestId('email')).toHaveText('alice@test.com');
8  await expect.soft(page.getByTestId('role-badge')).toHaveText('Admin');
9  await expect.soft(page.getByTestId('plan-badge')).toHaveText('Pro');
10
11  // Hard assertion — if the modal doesn't open, there's no point continuing
12  await page.getByRole('button', { name: 'Edit profile' }).click();
13  await expect(page.getByTestId('edit-modal')).toBeVisible();
14});
#soft assertions#expect.soft#non-blocking#collect failures