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

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Configure Playwright Test in playwright.config.ts: import defineConfig from @playwright/test, export a configuration object, place test-runner settings at the top level, and put shared browser settings inside use. Use projects for separate browsers or environments, and add webServer plus use.baseURL when tests should start and navigate a local app.

Create a Playwright configuration file

Playwright Test reads its configuration from a supported config file in your project. A common TypeScript filename is playwright.config.ts. The configuration imports defineConfig from @playwright/test and exports the options object as the default export. The official configuration guide and TestConfig API reference describe the supported layout; confirm options against the Playwright version installed in your project because the API can evolve.

Start with a small configuration and add options when a test requirement calls for them. This example sets a test directory, a shared base URL and trace behavior, and a Chromium project. It also starts a local server before the run:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
  testDir: './tests',
  use: {
    baseURL: 'http://localhost:3000',
    trace: 'on-first-retry',
  },
  projects: [
    {
      name: 'chromium',
      use: { ...devices['Desktop Chrome'] },
    },
  ],
  webServer: {
    command: 'npm run start',
    url: 'http://localhost:3000',
    reuseExistingServer: !process.env.CI,
  },
});

The snippet illustrates the documented configuration shape; it is not a claim that the command, test directory, or URL matches every repository. Adjust them to your app, package scripts, and CI setup.

#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

Where to save it and how to run it

Save the file in the project location from which you run Playwright Test. If the project uses another supported configuration format, the same distinction between runner-level options and browser/test options applies. Run your normal Playwright Test command, for example npx playwright test, from the project directory. If you keep the configuration elsewhere or use a non-default filename, consult the installed version’s CLI documentation for selecting that config.

Put each option at the right level

The most common configuration mistake is putting an option in the wrong object. Top-level settings control test discovery or the run as a whole; use configures the test browser and context. A project can override shared settings when a specific browser or group needs different behavior.

Location What it controls Examples
Top level Test collection, reporting, execution, or run-wide behavior testDir, timeout, globalTimeout, reporter, retries, workers, fullyParallel, forbidOnly, webServer
use Shared browser and test-context settings baseURL, browser/device options, viewport, storageState, trace, video
projects Named configurations for browsers, devices, environments, or test groups Project name and project-specific use options

For example, retries belongs at the top level when the same retry policy applies to the run, while a browser-specific policy can be defined on a project. Put baseURL in use, not at the top level. A project’s options are useful when a shared default needs to differ for only one configuration.

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

Configure browser and environment projects

Use projects when one test suite must run under more than one named configuration. A project commonly represents a browser or device profile, but projects can also separate environments or test groups. Each project has a name and can supply its own use settings.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

For instance, expand the starter project list to use the documented device descriptors:

projects: [
  {
    name: 'chromium',
    use: { ...devices['Desktop Chrome'] },
  },
  {
    name: 'firefox',
    use: { ...devices['Desktop Firefox'] },
  },
  {
    name: 'mobile-chrome',
    use: { ...devices['Pixel 7'] },
  },
],

Only include profiles you intend to support and run. Device descriptors configure a test profile; they do not mean that every real device or operating-system combination has been tested. Check that the descriptor names and browser availability match the Playwright version and browser installations in your project.

Choose parallelism and retries deliberately

Workers and full parallelism

Playwright runs test files in parallel by default, while tests within an individual file run in order in one worker unless you opt into parallel execution. The workers option limits concurrent worker processes; setting workers: 1 disables parallel scheduling. fullyParallel: true opts the run into parallel execution across tests. Parallel tests run in separate worker processes, so they cannot safely rely on shared in-memory state or a fixed execution order. These behaviors are described in the official parallelism guide.

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

More workers can raise concurrency, but the right value depends on test isolation and the resources available to the run. If tests interfere with shared accounts, records, ports, or other mutable state, fix the isolation boundary before increasing concurrency. Choose a smaller worker count when predictability or limited CI capacity matters more than parallel scheduling.

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

Retries are a diagnostic setting

Retries default to zero. You can set retries for the whole run or per project. The official retry guide calls a test that fails initially and passes on retry “flaky.” A retry can reveal instability, but it does not make the underlying test reliable; investigate timing, shared state, dependencies, and environment differences rather than counting a retry pass as an ordinary clean pass.

A common CI pattern is to enable a small retry count and restrict worker concurrency there, while keeping local retries off so failures are visible immediately. The example’s values are a starting point, not a universal CI prescription:

forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,

forbidOnly helps prevent a committed focused-only test from silently narrowing a CI run. Ensure your CI environment actually sets CI; otherwise these conditional values will not take effect.

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

Start a local app and use relative URLs

Set webServer when Playwright should run a command to start an application and wait for it to become ready. Its command starts the app; its url is the readiness address Playwright checks. Set use.baseURL to the same origin so tests can navigate with paths such as /login instead of repeating the full address. See the official web server guide.

Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
use: {
  baseURL: 'http://localhost:3000',
},
webServer: {
  command: 'npm run start',
  url: 'http://localhost:3000',
  reuseExistingServer: !process.env.CI,
},

With this configuration, a test can use await page.goto('/login'). The command and address must match the application’s actual start script and listening port. reuseExistingServer allows reuse of an already-running server outside CI in this example; in CI the setting is false, so the configured command is used instead.

If a run uses an array of multiple web servers, explicitly set baseURL. Do not assume that a readiness URL alone defines how relative navigation paths should resolve.

Useful options to add as your suite grows

Keep the config focused: add an option when it answers a real need, and avoid copying large option lists without understanding their scope.

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.
  • Test discovery: use testDir to point at the suite directory. Check the path relative to the config and the project’s layout.
  • Time limits: configure timeout for individual test behavior and globalTimeout when the whole run needs a bound. Verify exact semantics and defaults in the API reference for your installed version.
  • Results: set reporter to choose how the run reports outcomes. The example uses html; configure output handling to suit local use and CI artifact collection.
  • Browser context: use shared settings such as viewport, storageState, trace, or video under use. A project can override them for one browser or test group.
  • Environment separation: use projects to name distinct browser profiles, deployment targets, or test groups instead of scattering conditional behavior across tests.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot configuration problems

Playwright does not find the config or tests

  • Confirm the configuration file is in the project location from which the test command runs.
  • Check that testDir points to the actual tests directory and that the path is correct for the repository.
  • If you use a non-default config filename or location, select it using the CLI option supported by your installed Playwright version.

An option appears to have no effect

  • Check its scope: runner-level settings go at the top level, browser/context settings go under use, and project-specific behavior belongs in the matching project.
  • Look for a narrower project or test-level override that supersedes the shared setting.
  • Compare the option with the API reference for the version actually installed, especially after upgrading.

The local-server wait fails

  • Run the configured command manually and verify it starts the app without requiring an interactive prompt.
  • Check that the configured readiness url uses the port and address the app actually serves.
  • Make sure the server can start in the environment running the test, and investigate startup errors before adjusting test timeouts.
  • If multiple servers are configured, set use.baseURL explicitly so relative navigation has a clear origin.

Tests pass only after retry or fail under parallel load

  • Treat fail-then-pass results as flaky evidence and examine timing assumptions, external dependencies, and shared mutable data.
  • Check whether separate workers are colliding on accounts, records, or resources.
  • Use a lower worker count as a diagnostic or CI constraint; do not rely on retries as a substitute for isolation.

Or skip the browser setup

If your actual task is to capture a website screenshot rather than test an interactive application, ScreenshotNeo offers a website screenshot API and MCP server. A single GET request returns an image or PDF, so you do not need to configure a Playwright browser for that capture. See the ScreenshotNeo documentation for request options.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Cookie banners, popups, and chat widgets are removed before the shot; those cleanup steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 screenshots.

Sign up free for ScreenshotNeo to get 1,000 screenshots a month with no card.

Frequently Asked Questions

Can I use JavaScript instead of TypeScript for the Playwright config?

Yes. Playwright supports configuration file formats beyond TypeScript; use a format supported by the installed version and export the configuration in that format’s expected way.

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

Does `baseURL` start my application?

No. `baseURL` supplies the origin for relative navigation. `webServer` runs the application command and waits for its readiness URL.

Does passing on a retry mean a test is stable?

No. Playwright treats a fail-then-pass test as flaky; investigate its cause rather than treating the retry pass as a clean first-pass result.

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.