Is there an easy way to tell Playwright (JS) to take screenshots on test failure?
I'm quoting Playwright Docs about screenshots
// playwright.config.js file
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
screenshot: 'only-on-failure',
},
});
Screenshot setting modes are "off"|"on"|"only-on-failure"
in your case only-on-failure is what you're looking for.
As @sahmeepee mentioned in his comment, since v1.49 there is a new option on-first-failure that captures screenshot after each test's first failure only - relevant when setting up the retry mechanism.
export default defineConfig({
use: {
screenshot: 'on-first-failure',
},
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With