Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The default Playwright Test configuration file is playwright.config.ts (TypeScript) or playwright.config.js (JavaScript) in your current project directory. Playwright looks there automatically. Use --config or -c when the file has another name or location.

This guide explains where Playwright looks, what belongs in the file, documented defaults, a practical starter configuration, project setup, and the failures developers most often encounter.

What is the default Playwright config file?

Playwright Test recognizes these conventional filenames:

  • playwright.config.ts for a TypeScript configuration.
  • playwright.config.js for a JavaScript configuration.

The file is normally placed in the current directory from which you run Playwright. The configuration API describes testDir as defaulting to the configuration file’s directory. If both files exist, select the one you intend to use explicitly rather than relying on an ambiguous project layout.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

For a differently named file, pass its path on the command line:

npx playwright test --config=ci/playwright.config.ts
# The short form is also valid
npx playwright test -c ci/playwright.config.ts

The path may be relative to the directory where you run the command. This option is useful for separate local, CI, or browser-matrix configurations.

Where does Playwright look for the config?

Automatic lookup

Run npx playwright test from the directory containing playwright.config.ts or playwright.config.js. Playwright loads the conventional file and applies its settings to the test run. A common layout is:

project/
  playwright.config.ts
  tests/
    home.spec.ts
  package.json

If you invoke the command from another directory, the current working directory and the selected config path matter. Make the working directory explicit in CI, or always pass -c.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Explicit selection

Use -c when you have multiple configurations:

npx playwright test -c playwright.config.ts
npx playwright test -c configs/playwright.ci.config.ts

Keep the file extension consistent with the language and module setup used by your project. A configuration can be valid code and still fail to load if the command points to the wrong file.

What belongs in a Playwright configuration?

Playwright separates test-runner options from browser-context options. Runner settings go at the top level. Settings that describe the browser context shared by tests go inside use.

Top-level runner settings

The official basic example includes testDir, fullyParallel, forbidOnly, retries, workers, reporter, use, projects, and webServer. These options control discovery, parallel scheduling, safety checks, retries, worker limits, reporting, projects, and application startup.

Rank #2
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Shared browser settings in use

Put browser-context behavior such as baseURL inside use, not beside it. This distinction prevents a frequent configuration error: a test-runner option accidentally placed where a context option belongs, or vice versa.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A basic TypeScript configuration

This is a starting example, not a universal preset. Adjust browser coverage, CI capacity, retries, and server startup to your repository.

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

export default defineConfig({
  testDir: './tests',
  fullyParallel: true,
  forbidOnly: !!process.env.CI,
  retries: process.env.CI ? 2 : 0,
  workers: process.env.CI ? 1 : undefined,
  reporter: 'html',
  use: {
    baseURL: 'http://127.0.0.1:3000',
    trace: 'on-first-retry',
  },
  projects: [
    {
      name: 'chromium',
      use: { ...devices['Desktop Chrome'] },
    },
  ],
  webServer: {
    command: 'npm run start',
    url: 'http://127.0.0.1:3000',
    reuseExistingServer: !process.env.CI,
  },
});

The example chooses a tests directory, full parallel execution, a CI-only check for accidental test.only, two CI retries, one CI worker, an HTML reporter, a local base URL, a trace on the first retry, a Chromium project, and a local server. Those are example choices; a small project, a cross-browser suite, or a resource-constrained runner may need different values.

The equivalent JavaScript file

If your project uses JavaScript, create playwright.config.js with the same structure:

const { defineConfig, devices } = require('@playwright/test');

module.exports = defineConfig({
  testDir: './tests',
  fullyParallel: true,
  forbidOnly: !!process.env.CI,
  retries: process.env.CI ? 2 : 0,
  workers: process.env.CI ? 1 : undefined,
  reporter: 'html',
  use: {
    baseURL: 'http://127.0.0.1:3000',
    trace: 'on-first-retry',
  },
  projects: [
    {
      name: 'chromium',
      use: { ...devices['Desktop Chrome'] },
    },
  ],
  webServer: {
    command: 'npm run start',
    url: 'http://127.0.0.1:3000',
    reuseExistingServer: !process.env.CI,
  },
});

Use either the TypeScript or JavaScript file as your project’s convention. Do not maintain two active defaults unless you deliberately select one with -c.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Documented defaults you should know

Test discovery

By default, Playwright runs files matching .*(test|spec).(js|ts|mjs). A file such as tests/login.spec.ts matches. A file named login.ts does not match unless you change discovery settings or rename it.

Test timeout

Each test has a 30-second timeout by default. The timeout includes the test function, fixtures, and beforeEach hooks. Set a larger or smaller value when an application genuinely needs it, but avoid masking a slow or stuck test with an arbitrary increase.

Retries

Failed tests are not retried by default. Configure retries globally or per project. The example enables two retries only when the CI environment variable is set; local runs remain at zero retries so failures are visible immediately.

Workers

The API documentation says the default worker count is half the logical CPU cores. Worker limits affect parallel execution and may need adjustment to the memory and CPU available in CI.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Reporter

The documented default reporter is dot when the CI environment variable is set and list otherwise. The sample explicitly selects the HTML reporter so you can open a browsable report after a run.

Async expectation timeout

The API reference documents a default timeout of 5,000 milliseconds for asynchronous expect matchers. This is separate from the 30-second test timeout: increasing one does not automatically change the other.

Using baseURL and webServer correctly

baseURL resolves relative navigation

With use.baseURL set, a test can navigate with a relative path:

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

test('home page loads', async ({ page }) => {
  await page.goto('/');
  await expect(page).toHaveTitle(/Home/);
});

The browser resolves / against the configured base URL. Keep this setting under use.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

webServer starts and waits for the app

webServer runs a command and waits for the configured URL to become ready. It is useful when tests depend on a local development or preview server. It does not replace baseURL: webServer handles process startup and readiness, while baseURL supplies the URL used by test navigation. They are complementary.

If your CI pipeline starts the application elsewhere, omit webServer and set baseURL to that already-running service.

Projects for browsers, devices, and environments

A project is a named configuration variant. Projects let you run the same tests across browsers, devices, environments, or other settings. Each project can have its own browser or device profile, base URL, retries, and timeout.

projects: [
  {
    name: 'chromium',
    use: { ...devices['Desktop Chrome'] },
  },
  {
    name: 'mobile-chromium',
    use: { ...devices['Pixel 5'] },
  },
]

Choose projects based on the coverage you need and the capacity of the runner. More projects increase coverage but also increase run time and resource use. Run one project by name when diagnosing a failure:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
npx playwright test --project=chromium

How to create and verify the file

  1. Create playwright.config.ts or playwright.config.js in the directory from which you run Playwright.
  2. Export the configuration using the syntax appropriate to your project.
  3. Place runner settings at the top level and browser-context settings inside use.
  4. Put tests in the configured testDir, or rely on the config-file directory if you have not set one.
  5. Run npx playwright test. If the file is elsewhere, run npx playwright test -c path/to/file.
  6. Confirm that the expected test files match the default naming pattern and that any configured webServer URL becomes reachable.

Troubleshooting common configuration failures

“No tests found”

Check the current directory, the selected -c path, and the configured testDir. Then verify that filenames end in .test.js, .spec.js, .test.ts, .spec.ts, or the documented .mjs variants.

Playwright loads the wrong configuration

Multiple conventional files or a command run from the wrong directory can cause confusion. Pass an explicit path with --config and make that path part of the CI command.

“Cannot use import statement” or export errors

Use the TypeScript example only with a TypeScript-compatible Playwright setup and use the JavaScript export style expected by your project. Do not mix export default and module.exports in one file.

Relative URLs fail

Set use.baseURL. A webServer entry alone starts a process but does not tell page.goto how to resolve a relative path.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
Charlotte's Web: A Newbery Honor Award Winner – The Beloved Classic Novel About a Pig, a Spider, and the Power of Friendship
  • These are the words in Charlotte's web, high in the barn
  • Her spiderweb tells of her feelings for a little pig named Wilbur, as well as the feelings of a little girl named Fern … who loves Wilbur, too
  • Their love has been shared by millions of readers

The server never becomes ready

Run the server command manually, verify that it binds to the URL in webServer.url, and check that the port is available. If CI starts the app independently, remove webServer and point baseURL at the existing service.

Runs are too slow or unstable in CI

Review the number of projects and workers against available CPU and memory. The documented default worker count is half the logical CPU cores; an explicit CI limit such as one worker can reduce contention. Retries can help expose intermittent failures, but they do not fix the underlying cause.

HTML output is missing

The default reporter differs between CI and non-CI environments. Select reporter: 'html' when you require an HTML report regardless of environment.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is to obtain a clean website image rather than build an end-to-end browser test, ScreenshotNeo provides a single HTTP request. Its API accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing result in X-Page-Verdict and X-Billed headers.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

See the ScreenshotNeo documentation for all options, including full-page and selector captures, dark mode, device and viewport controls, retina scale, PDF output, custom CSS and JavaScript, clicks, waits, blocking rules, headers, cookies, user agents, authorization, timezone, geolocation, transparency, resizing, TTL caching, signed image links, asynchronous webhooks, bulk capture, usage, and the OpenAPI specification.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo also has an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

FAQ

Can I name the file something other than playwright.config.ts?

Yes. Pass the alternative path with --config or -c.

Is baseURL the same as webServer?

No. baseURL resolves relative navigation; webServer starts a process and waits for its URL.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Are failed tests retried automatically?

No. Retries are zero by default and must be configured.

What should I recheck after upgrading Playwright?

Verify defaults and option behavior against the documentation for the Playwright version installed in your project, because the documentation pages are rolling and the cited defaults are not tied to a publication year.

Quick Recap

SaleBestseller No. 1
HTML and CSS: Design and Build Websites
HTML and CSS: Design and Build Websites
HTML CSS Design and Build Web Sites; Comes with secure packaging; It can be a gift option
$15.75
SaleBestseller No. 2
Web Design with HTML, CSS, JavaScript and jQuery Set
Web Design with HTML, CSS, JavaScript and jQuery Set
Brand: Wiley; Set of 2 Volumes
$35.05
SaleBestseller No. 5
Charlotte's Web: A Newbery Honor Award Winner – The Beloved Classic Novel About a Pig, a Spider, and the Power of Friendship
Charlotte's Web: A Newbery Honor Award Winner – The Beloved Classic Novel About a Pig, a Spider, and the Power of Friendship
These are the words in Charlotte's web, high in the barn; Their love has been shared by millions of readers
$6.13

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.