How to take screenshot on failure

96 Views Asked by At

Is there an easy way to tell Playwright (JS) to take screenshots on test failure?

1

There are 1 best solutions below

0
I.sh. On

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.