Configurations Available In Playwright Config File


In this article, we will see how we can configure the playwright config file in order to run the test/spec files depending on your needs/configuration. 

We will look at each configuration items.



  • Refers the folder name which contains all the test/spec file.
  • By default while installing of playwright, tests will be configured in tests folder if you want you can change it accordingly.


timeout:30 * 1000

Maximum timeout a test can run. By default, it's set to 30000ms.

Expect Assertion Timeout

expect: {
 timeout: 5000

This timeout is for the expect assertion condition which you apply inside the tests. For example,if you have this assertion below

await expect(getStarted).toHaveAttribute('href', '/docs/intro');

The assert condition will wait for 5000 ms until it finds the element, if it does not find the element after 5000 ms then assertions fail and test will also fail



  • If you want to run your tests in parallel in CI/CD pipleline then provide true or else provide false.
  • Best option is to run your test in parallel because it saves the execution time of our tests.


forbidOnly: !!process.env.CI

If some of your tests are marked as test only accidentally while you are pushing the code and running your tests in CI/CD  then the build will fail with an error.

This will be helpful in CI/CD runs.


How many times do you want to retry a failed test in playwright we can provide the below values using this configuration.

retries: process.env.CI ? 2 : 0

here 2 is amount of retry when your tests run in CI/CD and 0 is amount of retry when the tests run in your local machine.


Amount of workers that is instantiated when your test runs.

workers:process.env.CI ? 1 : undefined

1 is the amount of workers instantiated in CI/CD. in place of undefined you can provide the value of workers which can get instantiated when you run your tests in your local machine.


We can configure the reporter that you need to view your results after your test runs. Default reporter value is HTML.

reporter: 'html'

the list of reporters available in playwright are

  • Html
  • Line
  • Dot
  • List
  • json
  • junit

other third party reporters which needs installation using npm can also be configured. Below are the third-party reporters supported

  • Allure
  • Monocart
  • Tesults
  • ReportPortal

We can configure the reporters as array values as shown below

reporter: [['html'],['line']]

Below configuration we need to set inside the use JSON object

 use: {
    actionTimeout: 0,
    baseURL: 'http://localhost:3000',
    trace: 'on',
    viewport: { width: 1280, height: 720 },


Action timeout is the time provided when each action is performed. Eg Click, Fill


headless: true/false

If you want to run your tests in headless mode we can provide the headless to true, if do not want to run your tests in headless mode then give false.


viewport: { width: 1280, height: 720 }

If you want to run your tests with a browser open with set width and height then use viewport configuration


if you want to record the video then provide the below values as per your needs.

  •  video:'off' - Do not record video.
  •  video:'on' - Record video for each test.
  •  video:'retain-on-failure' - Record video for each test, but remove all videos from successful test runs.
  •  video:'on-first-retry' - Record video only when retrying a test for the first time.

All the videos recorded will get stored in test-results folder plus the video will also get attached and displayed in html report.


Trace contains information regarding the execution of the script. If you want to record the trace then provide the below values as per your needs.

  • Trace:'off' - Do not record trace.
  • Trace:'on' - Record trace for each test.
  • Trace:'retain-on-failure' - Record trace for each test, but remove it from successful test runs.
  • Trace:'on-first-retry' - Record trace only when retrying a test for the first time.

Trace will be captured in .zip file under test-results folder in your project folder in addition to it the .zip folder will also appear in the HTML report. if you click on the trace section it will redirect to the trace webpage, user can see the timeline of how the test ran.

We can see the network logs, actions and before and after snapshots of the screens captured for each action. 

We can upload the trace zip file to the below website

Playwright Trace Viewer and view the execution of the scripts

Playwright Trace Viewer is a GUI tool that helps you explore recorded Playwright traces after the script has run.


If you want to take screenshots of the tests running, provide the values as per your needs.

  • Screenshot:'off' - Do not capture screenshots.
  • Screenshot:'on' - Capture a screenshot after each test.
  • Screenshot:'only-on-failure' - Capture a screenshot after each test failure.

All screenshots will get captured and stored in test-results folder in your project.

Networks configuration which you can use inside the use object

acceptDownloads - Download the attachments automatically 

ignoreHTTPSErrors - ignores the  HTTPS errors while navigation of page.

proxy- enable proxy setting while running your test 

httpCredentials - set http credentials for authentication.

Projects object

Configure the browsers on which you want to run your test on.

projects: [
      name: 'chromium',
      use: {
        ...devices['Desktop Chrome'],
      name: 'firefox',
     use: {
        ...devices['Desktop Firefox'],
      name: 'webkit',
     use: {
       ...devices['Desktop Safari'],


In this article, I have explained the configurations in playwright config file so that users can use it while running the playwright tests. Hope you find this article interesting and helpful while you are developing Playwright test Automation Project


Happy Learning...................