Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] traces zip files are not saved in the specified tracesDir #23645

Closed
talkohavy opened this issue Jun 11, 2023 · 3 comments · Fixed by #24086
Closed

[BUG] traces zip files are not saved in the specified tracesDir #23645

talkohavy opened this issue Jun 11, 2023 · 3 comments · Fixed by #24086
Assignees
Labels

Comments

@talkohavy
Copy link

System info

  • Playwright Version: [v1.34.3]
  • Operating System: macOS 13.2
  • Browser: Chromium

Source code

Config file

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

const config = defineConfig({
  testDir: './src/__tests__',
  outputDir: './__artifacts__',
  fullyParallel: true,
  retries: 1,
  testMatch: '*.test.js',
  reporter: [['html', { outputFolder: './__report__', open: 'on-failure' }]],
  use: {
    headless: false,
    baseURL: 'http://localhost:3000',
    testIdAttribute: 'data-test-id',
    trace: 'on-first-retry',
    launchOptions: {
      tracesDir: '__traces__',
    },
  },
  projects: [
    {
      name: 'chromium',
      use: {
        ...devices['Desktop Chrome'],
        launchOptions: {
          tracesDir: '__traces__',
        },
      },
    },
  ],
});

export default config;

Test file (self-contained)

// @ts-check
import { expect, test } from '@playwright/test';

test('this test will fail', async ({ page }) => {
  await page.goto('https://playwright.dev/');

  // Expect a title "to contain" a substring.
  await expect(page).toHaveTitle(/Play1wright/);
});

test('get started link', async ({ page }) => {
  await page.goto('https://playwright.dev/');

  // Click the get started link.
  await page.getByRole('link', { name: 'Get started' }).click();

  // Expects the URL to contain intro.
  await expect(page).toHaveURL(/.*int1ro/);
});

Steps

  • Simply run the test, it should fail. A retry would kick in. Which is good, because it is in compliance with trace: 'on-first-retry',.

Expected
The trace.zip file should have been stored within the tracesDir.

Actual

The trace.zip file is stored within the outputDir instead.

@aslushnikov
Copy link
Collaborator

@talkohavy traces are stored in the outputDir by the test runner by default; there's no way to configure it to be a separate directory.

Why would you want to do that?

@talkohavy
Copy link
Author

Well, it's not a matter of "why would I want to do that", it's a matter of "We've given you an option that doesn't work".

If you say "tracesDir", and then give a description that says "If specified, traces are saved into this directory.", then yes, I would expect it to work as mentioned.
Here's the type description:
Screenshot 2023-06-13 at 10 25 59

@yury-s
Copy link
Member

yury-s commented Jun 14, 2023

You are right, tracesDirdocumentation is misleading, Playwright will indeed store the traces in tracesDir when you use playwright library and launch the browser manually by calling e.g. chromium.launch({tracesDir}). In case of Playwright Test outputDir takes precedence and the traces are stored into that directory instead for the browsers created by Playwright fixtures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants