playwright-community / jest-playwright

Running tests using Jest & Playwright
MIT License
532 stars 75 forks source link

Automatic screenshot capture on failure #780

Closed npetridis closed 2 years ago

npetridis commented 3 years ago

Is your feature request related to a problem? Please describe.

Describe the solution you'd like I can see in the playwright config that they have an option to take screenshots on failure. How can we do this with jest-playwright? I tried it on jest-playwright.config.js but it didn't work

// jest-playwright.config.js
const browsers = process.env.CI ? {
  name: 'chromium',
  displayName: 'Chrome',
  launchType: 'LAUNCH',
  launchOptions: {
    headless: true,
    executablePath:
      process.env.CHROMIUM_BIN || '/usr/bin/google-chrome',
  },
} : 'webkit';

module.exports = {
  browsers: [
    browsers
  ],
  use: {
    screenshot: 'only-on-failure',
    trace: 'retain-on-failure',
  }
};

Any help would be appreciated. Thank you!

mxschmitt commented 3 years ago

This does not look like a Jest-Playwright configuration, you need to use @playwright/test fully if you want to leverage it's config. See here: https://playwright.dev/docs/intro

To have screenshots on failure with Jest see here: https://github.com/playwright-community/jest-playwright#usage-with-custom-testenvironment

But we recommend @playwright/test