playwright
playwright copied to clipboard
[Feature] Add config option to take screenshots in the exact moment of expect.soft() failure
Current situation
Given we set below in playwright.config.ts:
screenshot: {
mode: 'only-on-failure',
},
and the test fails on expect.soft() somewhere in the middle of the test and then proceeds to the end without any further issues - the screenshot is taken in the end of the test instead of the exact moment of failure which is not valuable to visually identify the problem.
Suggested solution
Allow user to choose whether to take just one screenshot at the end of failed test or to take multiple screenshots on each expect.soft() failure during test execution. Suggested new ScreenshotMode:
type ScreenshotMode = 'off' | 'on' | 'only-on-failure' | 'on-each-soft-failure';
Alternatively allow to configure expect to take screenshots on soft failures:
expect: {
screenshotOnSoftFailure: true,
timeout: 20_000,
},