microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
66.4k stars 3.63k forks source link

[Bug]: Playwright ignores the recording configuration set in the playwright.config.js. #29806

Closed RodrigoOBC closed 7 months ago

RodrigoOBC commented 7 months ago

Version

1.41.1

Steps to reproduce

Playwright ignores the video configuration within the playwright.config.js file. Inside my playwright.config.js file, I can put any information in the video key, and it ignores it as if nothing were there. This doesn't happen with screenshots and doesn't happen with traces, only with video.

use: {
    /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
    actionTimeout: 0,
    /* Base URL to use in actions like `await page.goto('/')`. */
    baseURL: process.env.BASE_URL,
    trace: process.env.TRACEVIEW,
    video: "retain-on-failure",
    screenshot: process.env.SCREENSHOT,
    /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
    headless: true,
    locale: 'pt-BR'
  },

I didn't include the entire config because it contains sensitive data. But if necessary, I can provide it with the data removed. In some research, it was mentioned that the following key-value pair needed to be added:

outputDir: 'test-results/',

I added it to my config, however, the result remains the same. It continues to ignore what I place there.

Expected behavior

Option to record the video when the test encounters a failure.

Actual behavior

The Playwright ignores the option to record videos of tests with failures.

Additional context

No response

Environment

System:
    OS: Linux 5.15 Ubuntu 20.04.6 LTS (Focal Fossa)
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 4.79 GB / 7.61 GB
    Container: Yes
  Binaries:
    Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 10.2.5 - /workspaces/Teste-Automatizado/node_modules/.bin/npm
  IDEs:
    VSCode: 1.87.0 - /vscode/vscode-server/bin/linux-x64/019f4d1419fbc8219a181fab7892ebccf7ee29a2/bin/remote-cli/code
  Languages:
    Bash: 5.0.17 - /usr/bin/bash
  npmPackages:
    @playwright/test: ^1.41.1 => 1.41.1 
    playwright: ^1.41.1 => 1.41.1 
    playwright-video: ^2.4.0 => 2.4.
dgozman commented 7 months ago

@RodrigoOBC Are you using serial mode (see #14813) or persistent context (#11833) by any chance? If not, we would need a full self-contained repro to figure out the problem, not just a snippet from your config file.

RodrigoOBC commented 7 months ago

Hi, I use in my tests parallelism. I always run with 3 set workers, and this is my complete configuration:

require('dotenv').config()

// @ts-check
const { devices } = require('@playwright/test');
const dotenv = require('dotenv');
const path = require('path');

/**
 * Read environment variables from file.
 * https://github.com/motdotla/dotenv
 */

dotenv.config({ path:path.join(__dirname,'utils', '.env') })
process.env.ALLURE_PROJECT_NAME = 'cofidential data';

/**
 * @see https://playwright.dev/docs/test-configuration
 * @type {import('@playwright/test').PlaywrightTestConfig}
 */

const config = {
  globalTeardown: "./utils/global.teardown.js",
  testDir: './features/tests/',
  timeout: 99000,
  expect: {

    timeout: 99000
  },

  fullyParallel: true,

  retries: parseInt(process.env.RETRIES) ,

  reporter: [['line'],[
    "allure-playwright",
    {
      detail: true,
      outputFolder: "temp",
      suiteTitle: false,
      name: "Nexus",
      environmentInfo: {
        Node_Version: process.version,
        OS: process.platform,
           },
           projectName: 'cofidential data'
    },
  ]],
  /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
  use: {
    /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
    actionTimeout: 0,
    /* Base URL to use in actions like `await page.goto('/')`. */
    baseURL: process.env.BASE_URL,
    trace: process.env.TRACEVIEW,
    video: process.env.VIDEO,
    screenshot: process.env.SCREENSHOT,
    /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
    headless: true,
    locale: 'pt-BR'
  },

  /* Configure projects for major browsers */
  projects: [
    {
      name: 'chromium - En',
      use: {
        ...devices['Desktop Chrome'],
        viewport: { width: 1366, height: 768 },
        locale:'en-US'

      },
      testMatch: '**/*.en.@(spec|test).?(c|m)[jt]s?(x)',
    },
    {
      name: 'chromium',
      use: {
        ...devices['Desktop Chrome'],
        viewport: { width: 1366, height: 768 },
        locale:'pt-BR'
      },
      testIgnore: ['**/*.en.@(spec|test).?(c|m)[jt]s?(x)'],
    },
  ],

  /* Folder for test artifacts such as screenshots, videos, traces, etc. */
  outputDir: 'test-results/',

};

module.exports = config;

exemples env:

SCREENSHOT=only-on-failure
TRACEVIEW=retain-on-failure
VIDEO=retain-on-failure
dgozman commented 7 months ago

@RodrigoOBC I don't see anything suspicious in this config, so we will need a full self-contained repro to tackle this issue. Otherwise, I will have to close it as non-reproducible.

dgozman commented 7 months ago

We have to reproduce this issue locally to be able to debug it. If you can provide a full repro, please file a new issue by filling the "Bug Report" template, and link to this one.