Rayrun

How do I prevent Playwright from creating a 'test-results' folder after running a test?

Answer

Disabling 'test-results' Folder Creation in Playwright

Yes, you can stop Playwright from creating a 'test-results' folder. This folder is where test artifacts are stored by default. But you can change this or disable it.

Using the Command Line

Use the --output option when running Playwright tests from the command line. By default, it's set to test-results. You can change it to any directory or an empty string to disable it.

Here's how to run tests without creating a 'test-results' folder:

npx playwright test --output ""

This command stops Playwright from creating any output directory for test artifacts.

Using a Configuration File

If you're using a configuration file (playwright.config.ts or playwright.config.js), you can pass options directly in it. Define the reporter property with an array containing 'html' as the first element and specify additional options within an object.

Here's how to configure Playwright in your configuration file to disable the 'test-results' folder:

import { defineConfig } from '@playwright/test';

export default defineConfig({
  reporter: [['html', { outputFolder: '' }]],
});

In this example, we set the outputFolder option to an empty string (''). This effectively stops creating any output folder for test results.

These methods let you customize where Playwright stores test artifacts or disable their creation. This gives you flexibility in managing your test results according to your needs.

References

Thank you!
Was this helpful?
Still have questions?

If you still have questions, please ask a question and I will try to answer it.

Related Discord Threads

Related Questions

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

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 luc@ray.run.