Playwright + TS · Lesson 33 of 36
Module 33: Parallel & Cross-Browser Testing
Try it yourself
Implement calculateOptimalWorkerCount:
The editor has a worked example. Read it, tweak it, then press Mark as complete.
In this lesson
test.describe.configure({ mode: 'parallel' });.playwright.config.ts)import { defineConfig, devices } from "@playwright/test";
export default defineConfig({
workers: process.env.CI ? 2 : undefined, // Auto-detect CPUs locally
projects: [
{
name: "Desktop Chrome",
use: { ...devices["Desktop Chrome"] },
},
{
name: "Desktop Firefox",
use: { ...devices["Desktop Firefox"] },
},
{
name: "Desktop Safari",
use: { ...devices["Desktop Safari"] },
},
{
name: "Mobile iPhone 14",
use: { ...devices["iPhone 14"] },
},
],
});When a small set of tests MUST run in order:
test.describe.serial("Order Processing Pipeline", () => {
test("create order", async () => { /* ... */ });
test("process payment", async () => { /* ... */ });
test("ship order", async () => { /* ... */ });
});To give fast feedback to developers, large test suites need to run in parallel. In this lesson, we will explore Playwright's multi-worker process architecture, test isolation, serial test modes, and cross-browser testing matrices across Chromium, Firefox, WebKit, and mobile viewports. Let's scale our test execution!
Part of the Playwright + TS course (Playwright with TypeScript). Practice this concept live in the Playwright Online Compiler or explore our free automation practice form.
No. Each worker is an independent Node.js process. Global in-memory variables set in one test file will NOT exist in another worker.
Playwright configures the viewport, deviceScaleFactor, userAgent, and touch screen emulation using the Chromium/WebKit engine.
Finished reading?
Review the worked example in the editor, then mark the lesson complete.