Rayrun
← Back to Discord Forum

Trace disabled in config, but still generated?

sgtoneill.ptposted in #help-playwright
Open in Discord
sgtoneill.pt

Hello everyone, I trying out Playwright for the first time. I was checking the config file and opted to disable trace in the use property, however, I still get the test-result folder with trace.zip for each test I run.

Is this normal?

This thread is trying to answer question "Why are trace files still being generated in Playwright despite being disabled in the configuration file?"

20 replies
sgtoneill.pt
export default defineConfig({
  use: {
    baseURL: 'http://localhost:5173',
    trace: 'off',
  },
ibrahim.bektas
ibrahim.bektas

Can you post the whole playwright.config.ts?

sgtoneill.pt

Sure

export default defineConfig({
  use: {
    baseURL: 'http://localhost:5173',
    trace: 'off',
    screenshot: 'off',
    video: 'off',
  },
  fullyParallel: true,
  forbidOnly: true,
  projects: [
    {
      name: 'chromium',
      use: {
        ...devices['Desktop Chrome'],
      },
    },
    {
      name: 'firefox',
      use: {
        ...devices['Desktop Firefox'],
      },
    },
    {
      name: 'webkit',
      use: {
        ...devices['Desktop Safari'],
      },
    },
    {
      name: 'Mobile Safari',
      use: {
        ...devices['iPhone 12'],
      },
    },
  ],
})
sgtoneill.pt

I thought "projects" were overwriting the first use and tried adding trace: "off" in each project, but I still get the trace files 🤔

perhaps try trace: { mode: 'off' } although your config should also work

sgtoneill.pt

same result, it created the test-result folder with trace.zip files

what is your playwright version?

sgtoneill.pt

"@playwright/test": "1.36.2",

🤷‍♂️ , can't reproduce

sgtoneill.pt

WHen you run tests with --UI , it does not create the zip files?

sgtoneill.pt

Im starting to think that, running --UI will always create the zip files, it seems that they are used to show in the interface

ah, that's different

ui mode does live tracing as it is running the test so I guess it has to save traces somewhere

might be a bit weird considering config but I think that's expected behavior if you're using ui mode

sgtoneill.pt

ahh got it. --ui will always create the traces

sgtoneill.pt

i tried running without UI and it doesn't create the test-result folder with traces

sgtoneill.pt

that must be it

yeap

sgtoneill.pt

I think i'll git ignore this folder and turn traces on for CI

sgtoneill.pt

Thanks 👍

Answer

Disabling Trace.zip Files in Playwright

Yes, it's normal to see a 'test-result' folder with 'trace.zip' for each test run in Playwright, even after disabling trace in the config file. This is because Playwright is set up to create a trace.zip file for each test run by default.

However, you can control this behavior through the configuration options in the playwright.config.ts file. If you want to completely disable tracing, you can modify this file accordingly.

Here's how you can do it:

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

export default defineConfig({
  use: {
    trace: 'off',
  },
});

By setting trace: 'off', Playwright will no longer generate trace.zip files for any tests.

Remember, if you have already executed tests with tracing enabled, disabling tracing will not remove those existing files. It only prevents new trace.zip files from being created during subsequent test runs.

So, to completely stop generating new trace.zip files, make sure to set trace: 'off' in your playwright.config.ts file.

Related Discord Threads

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 [email protected].