JustHandled Labs
// browser testing guide

How to test a web app before launch with Playwright

Do not start by clicking every page. Name the few journeys whose failure costs an activation, payment, or support ticket; run them as isolated browser tests; and keep enough evidence to reproduce the first failure.

The short version

Test signup, login, the first useful action, checkout or upgrade, and recovery before polishing peripheral pages. Use role- and label-based locators, web-first assertions, disposable test data, and a deterministic local or staging environment. Capture console errors, page exceptions, screenshots, and a trace on failure. Add one iPhone-like and one Android-like project after the desktop journey is stable. A green run proves only those named steps and assertions.

Release path

1. Choose the five journeys that can stop a launch

A route inventory is not a test plan. Start with money and activation: what must a new user complete, what must a returning user recover, and which step hands off to an external provider?

JourneyObservable resultFailure worth preserving
SignupAccount exists and the user reaches the intended first screen.Validation loop, missing confirmation, duplicate-account conflict.
LoginCorrect role lands on the correct authenticated surface.Cookie never persists, redirect loop, wrong role or tenant.
First valueThe user completes the product's core action with real application state.Fake success, stale state, swallowed API error.
UpgradeSandbox checkout opens with the expected product and return path.Wrong mode, wrong price, broken success or cancel URL.
RecoveryPassword reset, retry, or saved work returns the user to a usable state.Expired token, lost form state, unrecoverable error screen.

Write the expected visible outcome before recording clicks. If the test cannot state what success looks like to the user, it cannot distinguish a real completion from a convincing screen.

2. Control the environment before interpreting a failure

A

Reuse the project's real start command

Inspect the package manager, existing Playwright configuration, environment files, and service dependencies. Playwright's webServer option can start a local server and wait for its URL before the suite begins.

B

Use deterministic data

Playwright recommends controlling the database and avoiding tests that depend on third-party pages you do not control. Seed disposable accounts, use provider sandboxes, and reset state between tests.

C

Define the production boundary

Production smoke tests should be read-only unless the owner approves a sandboxed mutation. Do not charge a card, send an email, publish content, or create customer-visible data merely to make a test pass.

Preflight record

  • Target URL and environment.
  • Start command and readiness URL.
  • Test accounts, data reset, and provider sandbox.
  • Allowed mutations and prohibited side effects.
  • Browser and device projects selected for this run.

3. Use the interface a user can perceive

Playwright recommends role, label, text, and explicit test-ID locators over CSS classes, DOM nesting, and XPath. Its locators auto-wait for actionability, and its web-first assertions retry until the expected state appears or the assertion times out.

await test.step('submit a valid signup', async () => {
  await page.getByLabel('Email').fill(testUser.email);
  await page.getByRole('button', { name: 'Create account' }).click();
  await expect(page.getByRole('heading', { name: 'Import your project' }))
    .toBeVisible();
});
  • Name each test.step() as a user action or result.
  • Assert the visible success state, URL, persisted record, or provider handoff—not merely that a click occurred.
  • Avoid fixed sleeps. Wait on a user-visible state, response, URL, or stable locator.
  • Do not test an external provider's entire UI. Verify the handoff you control and use its sandbox contract.

4. Reuse authentication without leaking it

Playwright can create an authenticated storage-state file in a setup project and reuse it across tests. That file can contain cookies and headers capable of impersonating the account, so the official documentation says to keep it in a gitignored playwright/.auth directory.

  • Use disposable or staging-only accounts.
  • Commit the setup code, never the generated state file.
  • Use separate accounts when tests mutate shared server-side state in parallel.
  • Delete or regenerate state when credentials expire or permissions change.
  • Mask credentials and tokens in logs, screenshots, and traces before sharing artifacts.

5. Save the evidence that explains the first failure

A screenshot shows one frame. A useful failure record also preserves the step, URL, console, page exception, network clue, and trace. Playwright's trace viewer can show the action timeline, DOM snapshots, console, network, and source around a failed step.

Failure record

  • Named step and expected state.
  • Actual URL and visible error.
  • Console errors and uncaught page exceptions.
  • Response status for the failing application request.
  • Screenshot and trace paths.
  • Likely source file or service boundary.
  • Reproduction command and browser project.

Configure traces on the first retry or for focused debugging rather than recording every test indefinitely; Playwright notes that always-on tracing is performance-heavy.

6. Add device coverage after the core journey is stable

Playwright projects can emulate desktop browsers and mobile devices. Begin with the browser that matters most to the release, then add an iPhone-like and Android-like project for layout-sensitive flows. Check that navigation, fields, primary actions, error messages, and overflow remain visible and usable.

Device emulation does not reproduce every physical-device behavior. Treat it as repeatable viewport, input, and browser evidence; use real-device testing separately when hardware, camera, push, WebView, or platform-specific behavior matters.

ResultWhat it provesWhat remains open
Desktop passThe named journey and assertions passed in the selected desktop project.Other engines, screen sizes, permissions, and untested branches.
Mobile passThe named controls and outcomes worked under the selected emulation profile.Physical-device APIs, keyboards, network conditions, and browser chrome.
Visual passThe stable screenshot matched its reviewed baseline within configured tolerances.Dynamic regions, content correctness, accessibility, and behavior outside the image.

Turn the plan into a browser evidence report

Webapp TesterA focused SKILL.md workflow for Playwright setup, login, checkout, forms, responsive projects, visual checks, console capture, screenshots, traces, and step-level reporting. It asks before production mutations and does not turn a green run into a blanket launch certification.See the browser-testing skill →

Common questions

Which web app flows should I test first?

Start with the journeys whose failure blocks activation or payment: signup, login, the first useful action, checkout or upgrade, and account recovery. Add the riskiest role or permission boundary when the app has multiple user types.

Should Playwright tests run against local, staging, or production?

Develop and debug against a deterministic local or staging environment. Use production only for read-only smoke checks or explicitly approved sandbox paths. Do not charge cards, send email, publish content, or mutate real customer data during an unapproved test.

How should Playwright tests locate buttons and fields?

Prefer user-facing roles, labels, text, and explicit test IDs over CSS classes, DOM nesting, or XPath. Playwright locators auto-wait and are more resilient when they follow the interface a user can perceive.

Is Playwright storage state safe to commit?

No. Playwright warns that saved browser state can contain cookies and headers capable of impersonating the test account. Keep it in a gitignored playwright/.auth directory and use disposable or non-production credentials.

Does a green Playwright run prove a web app is ready to launch?

No. It proves only the named journeys, assertions, browsers, and devices that ran. Security, load, accessibility, untested business rules, third-party behavior, and production configuration still require separate evidence.

Primary references

Test the journey that pays for the app.

Webapp Tester turns a named user flow into Playwright tests and a step-level evidence report across the browsers and devices you choose. Use sandbox credentials and approve any production mutation first.

Get Webapp Tester on Agensi