Testing / Playwright Interview questions
What is the difference between soft assertions and hard assertions in Playwright?
A regular ("hard") assertion stops the test immediately the moment it fails - any code after it never runs.
| Hard assertion | Soft assertion |
| expect(locator).toBeVisible() | expect.soft(locator).toBeVisible() |
| Test stops at first failure | Test continues after failure |
| One failure reported | All soft failures reported together at the end |
Soft assertions, written as expect.soft(...), record a failure but let the test keep executing so later checks still run - useful when verifying several independent pieces of a page (like multiple form fields) and wanting one report covering everything that's wrong, rather than fixing issues one failure at a time across repeated runs.
The test itself is still ultimately marked as failed if any soft assertion recorded a problem; the difference is only in whether execution continues afterward, and every recorded soft failure shows up individually in the final report and in testInfo.errors.
More Related questions...