Full Stack Engineer: Deterministic Playwright E2E Test Sharding, Auth StorageState & Network Isolation in CI/CD

End-to-end (E2E) browser test suites often become a bottleneck in engineering organizations because tests log in through the UI before every single spec, rely on arbitrary page.waitForTimeout(3000) sleeps, and fail intermittently when third-party analytics or sandbox APIs experience latency spikes. As a Full Stack Engineer, I architect deterministic Playwright test pipelines with pre-authenticated storageState setup projects, web-first assertions, and matrix sharding that run 300+ E2E specs in under 4 minutes in GitHub Actions.

1. Eliminating Repetitive Login Flows with Setup Projects & storageState

Executing an OAuth or session login flow 250 times across a test run wastes minutes of CI compute. Instead, we configure a dedicated Playwright setup project that authenticates once via API or UI, persists HTTP-only cookies and localStorage tokens into .auth/tenant-admin.json, and injects that state into all downstream browser workers automatically:

// playwright.config.ts
import { defineConfig, devices } from "@playwright/test";

export default defineConfig({
  testDir: "./e2e",
  fullyParallel: true,
  retries: process.env.CI ? 2 : 0,
  workers: process.env.CI ? 4 : undefined,
  reporter: [["html", { open: "never" }], ["blob"]],
  use: {
    baseURL: process.env.PLAYWRIGHT_BASE_URL || "http://127.0.0.1:3000",
    trace: "on-first-retry",
    screenshot: "only-on-failure",
  },
  projects: [
    {
      name: "auth-setup",
      testMatch: /.*\.setup\.ts/,
    },
    {
      name: "chromium-authenticated",
      use: {
        ...devices["Desktop Chrome"],
        storageState: "playwright/.auth/tenant-admin.json",
      },
      dependencies: ["auth-setup"],
    },
  ],
});

2. Deterministic Network Boundary Mocking & Visual Accessibility Assertions

While internal backend APIs (Next.js Route Handlers, Django Ninja, and PostgreSQL) should run against real containers in CI—as shown in our Docker Compose multi-service topology guide—volatile external third-party endpoints are intercepted via page.route() with deterministic HAR fixtures. We also embed automated @axe-core/playwright WCAG contrast and keyboard-navigation audits into every critical user journey across our Full Stack Engineer Next.js 15 & React 19 applications.

Need a Full Stack Engineer to eliminate flaky E2E tests and build fast Playwright CI pipelines? Book a 1-Day Engineering Sprint.


About the Author — Hire Aldian Fazrihady (Cloud Engineer, GCP Professional Cloud Architect, GCP Professional Data Engineer, Backend, AI & Full Stack Engineer)

Aldian Fazrihady is a Top-Rated Senior Cloud Engineer, GCP Professional Cloud Architect (Google Cloud Certified), GCP Professional Data Engineer (Google Cloud Certified), Backend Engineer (Python, Django, FastAPI, Go, PostgreSQL), AI Application Engineer (LLMs, RAG, MCP, Google ADK, LangGraph), and Full Stack Engineer (React, Next.js, TypeScript) with 15+ years of production software engineering experience.

Hire Aldian Fazrihady on Upwork | Book 1-Day Programming Service ($100 USD / Rp 1.000.000) | View Live AI Portfolio | Send a Direct Message

Related Engineering Articles

Engineering Role Pillar Guides & Category Hubs