This thread is trying to answer question "Is there a way to prevent tests from being skipped if one fails when using the Playwright test runner?"
Nope @debbieobrien , In mocha or jest, to achieve the same we set bail = false in the resepective config file, can I do the same with playwright test runner ?
I am not seeing for the soft assertions, I want my rest of the tests to be executed even when any of the test is failed in between, as my tests are completely independent.
can you please suggest for the above
@debbieobrien Sorry usually don't direct message, but was wondering if you all might provided some setting on this. Meaning should an expect().toBeXXXX() hard kill the variation. Sure one can use expect.soft() but in development might be times i want to allow test to get past one expct in order to more easily write my tests. Then in an offical test run i any of the plain 'expect().toBeXXX()' fail fast:
So a setting in the PW.Config.ts.... { name: "Desktop", use: { ...devices["Desktop Chrome"], viewport: { width: 1200, height: 6500 }, baseURL: ENV.URL, locale: "en-US", expect: [(FailFast|FailSoft), ScreenShot, other,...?]
Lack of a beter way my regex pattern for the options... FailFast -- Current behavior to end current test FailSoft -- Any expect will behave as a "expect.soft(); ScreenShot -- would create a screen shot of the UI at the point the exception occurred, could be used with expect.soft()...
Thanks just hope i'm not abusing the ping ๐
no worries. You can configure your own so that you always do soft assertions and then change it to true but this is at test level. https://playwright.dev/docs/test-assertions#expectconfigure What you are looking for looks like a feature request to me as you want it in the config. Why don't you submit that as a request on our GitHub and the team can look into it.
No, the only other solution would be to design your tests such that they can run independently and then you wouldn't need to use serial mode. If a test fails, even on a soft assertion, the runner assumes that following tests must be skipped because of being in serial mode.
Related Ask AI answer for "What is the method to continue with the rest of the tests even if one fails in Playwright test runner?".
In Playwright, you can handle test failures in two ways: fail fast or fail soft.
test.fail()
The test.fail()
function in Playwright marks a test as "should fail". When this test runs, Playwright ensures it fails. This is useful for acknowledging broken functionality until it's fixed. Here's how you use it:
import { test } from '@playwright/test';
test('not yet ready', async ({ page }) => {
test.fail();
// ... rest of your code
});
If you want to continue running all tests even if some fail, use soft assertions. These don't immediately terminate the execution when failed. Instead, they compile and display a list of failed assertions once all tests have ended. Here's an example:
import { expect } from '@playwright/test';
await expect.soft(page.getByTestId('status')).toHaveText('Success');
// ... continue executing more checks or actions
With soft assertions, even if one assertion fails, other checks or actions will still be executed. Any subsequent failures will be recorded and displayed at the end of the test execution.
So, depending on your needs, you can use test.fail()
for a fail fast approach, or soft assertions with expect.soft()
to continue executing all tests and fail soft.
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 [email protected].