NEWUse coupon code SMX20 to get 20% OFF your first billing cycle on any game server or VPS!Explore Store

VPS HOSTING

How to Run Automated End-to-End Tests with Playwright on a Linux VPS

Run Playwright browser tests headlessly on a Linux VPS: install browsers and system dependencies, configure workers and retries, test against staging, schedule runs, keep traces and reports, and size the server.

End-to-end tests drive a real browser through your application the way a user would: log in, add to cart, pay, check the confirmation. They catch problems that unit tests miss, but they need real browsers and a fair amount of CPU. A Linux VPS is a good place to run them: always available, faster than a laptop for parallel runs, and close to your staging server. This guide uses Playwright, which supports Chromium, Firefox and WebKit from one API.

Step 1: Install Node.js and Playwright

Use a current Node.js LTS release, then add Playwright to your project (or a dedicated tests repository):

npm init playwright@latest
# or in an existing project
npm install -D @playwright/test
npx playwright install --with-deps

--with-deps installs the system libraries the browsers need on Debian and Ubuntu, which is the most common cause of "browser failed to launch" errors on a fresh server. To save time and disk, install only what you test: npx playwright install --with-deps chromium.

Step 2: Configure for a Server

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

export default defineConfig({
  testDir: './tests',
  fullyParallel: true,
  workers: 4,                 // about one per vCore
  retries: 1,                 // retry once to spot flaky tests
  timeout: 30_000,
  reporter: [['html', { open: 'never' }], ['list']],
  use: {
    baseURL: process.env.BASE_URL ?? 'https://staging.example.com',
    trace: 'on-first-retry',
    screenshot: 'only-on-failure',
    video: 'retain-on-failure',
  },
  projects: [
    { name: 'chromium', use: { ...devices['Desktop Chrome'] } },
    { name: 'mobile', use: { ...devices['Pixel 7'] } },
  ],
});

Headless mode is the default, so no display server is needed. Retries reveal flaky tests: a test that passes on retry is reported as "flaky", which you should fix rather than ignore.

Step 3: A Sample Test

// tests/login.spec.ts
import { test, expect } from '@playwright/test';

test('user can log in', async ({ page }) => {
  await page.goto('/login');
  await page.getByLabel('Email').fill(process.env.E2E_USER!);
  await page.getByLabel('Password').fill(process.env.E2E_PASS!);
  await page.getByRole('button', { name: 'Sign in' }).click();
  await expect(page.getByRole('heading', { name: 'Dashboard' })).toBeVisible();
});

Use role- and label-based locators, which are more stable than CSS selectors, and keep test credentials in environment variables, never in the repository.

Step 4: Run and Read Results

BASE_URL=https://staging.example.com npx playwright test
npx playwright show-report --host 127.0.0.1   # view via SSH port forwarding
npx playwright show-trace test-results/**/trace.zip

The HTML report and traces show each step, network request, console message and DOM snapshot, which makes failures on a headless server easy to debug. View them on your computer through SSH port forwarding, or copy the playwright-report folder down.

Alternative: The Official Docker Image

Microsoft publishes Playwright images with browsers and dependencies preinstalled. Match the image tag to your @playwright/test version:

docker run --rm --ipc=host -v "$PWD":/work -w /work \
  -e BASE_URL=https://staging.example.com \
  mcr.microsoft.com/playwright:vX.Y.Z-noble \
  npx playwright test

Replace vX.Y.Z with your installed version. --ipc=host is recommended for Chromium to avoid running out of shared memory. Containers keep the server clean and make runs reproducible.

Step 5: Automate Runs

  • From CI: register the VPS as a self-hosted runner for GitHub Actions or GitLab CI and run the suite on every merge to the main branch.
  • On a schedule: a nightly cron job runs the full suite against staging or production smoke tests (see our cron guide).
  • After deploys: call the test command from your deploy script and roll back if critical tests fail.
# crontab -e  (02:30 every night)
30 2 * * * cd /srv/e2e && BASE_URL=https://staging.example.com npx playwright test --reporter=line >> /var/log/e2e.log 2>&1

Send failures somewhere you will see them, for example a webhook to chat, or a heartbeat monitor that alerts when the nightly run stops reporting success (see our monitoring guide).

Making Tests Reliable

  • Rely on Playwright's auto-waiting assertions (expect(...).toBeVisible()) instead of fixed sleeps.
  • Give each test its own data, or reset the database before the run, so tests do not depend on each other.
  • Reuse a logged-in state with storageState instead of logging in through the UI in every test.
  • Run against staging, not production, except for read-only smoke tests.
  • Keep the server close to the application under test to reduce network flakiness.

Splitting Large Suites

When one server is not enough, split the suite into shards and run them on several machines in parallel: npx playwright test --shard=1/3, --shard=2/3 and --shard=3/3. Each shard produces a blob report, and npx playwright merge-reports combines them into one HTML report. This scales test time down roughly linearly with the number of servers.

Sizing the Server

Each browser worker typically needs about one CPU core and several hundred MB to more than 1 GB of RAM depending on the pages. Start with workers equal to the vCore count and reduce them if you see timeouts or memory pressure. Clean old reports, traces and videos regularly; they use disk quickly.

ServoMix Plans for This Workload

Each headless browser worker uses roughly a CPU core and several hundred MB to over 1 GB of RAM under load. A 4 vCore / 16 GB server runs four parallel workers comfortably; scale vCores with the number of workers you want.

AMD EPYC 7C13 VPS

Dedicated KVM vCores on AMD EPYC 7C13 (up to 3.70 GHz) with DDR4 ECC memory, NVMe SSD and an unmetered 1 Gbps port.

PlanvCoresRAMStorageNetworkPriceGood forBuy
SMX vPro XS (AMD EPYC)28 GB DDR4 ECC40 GB NVMe SSD1 Gbps, unmetered₹420/moWebsites, small APIs, bots, staging and VPN serversOrder
SMX vPro S (AMD EPYC)416 GB DDR4 ECC80 GB NVMe SSD1 Gbps, unmetered₹560/moWooCommerce, Node.js/Python backends, Docker Compose stacks, CI runnersOrder
SMX vPro M (AMD EPYC)832 GB DDR4 ECC150 GB NVMe SSD1 Gbps, unmetered₹840/moProduction databases, high-traffic sites, multi-container appsOrder
SMX vPro L (AMD EPYC)1664 GB DDR4 ECC250 GB NVMe SSD1 Gbps, unmetered₹1,120/moLarge production workloads, SaaS platforms, analytics, in-memory cachesOrder

Intel Xeon Platinum 8269CY VPS

KVM VPS on Intel Xeon Platinum 8269CY (up to 3.80 GHz Turbo) with DDR4 ECC memory, NVMe SSD, full root access and an unmetered 1 Gbps port.

PlanvCoresRAMStorageNetworkPriceGood forBuy
SMX vCore XS (Intel Xeon)28 GB DDR4 ECC40 GB NVMe SSD1 Gbps, unmetered₹270/moBusiness websites, small apps, scheduled jobs and botsOrder
SMX vCore S (Intel Xeon)416 GB DDR4 ECC80 GB NVMe SSD1 Gbps, unmetered₹1,169/monthBusiness software, mid-size databases, several sites on one serverCheck stock
SMX vCore M (Intel Xeon)832 GB DDR4 ECC150 GB NVMe SSD1 Gbps, unmetered₹2,249/monthERP/CRM stacks, heavier databases, multiple production appsCheck stock
SMX vCore L (Intel Xeon)1664 GB DDR4 ECC250 GB NVMe SSD1 Gbps, unmetered₹4,248/monthHigh-memory workloads and consolidated production serversCheck stock

Prices are monthly in INR as listed on the ServoMix store (verified 2026-11-14). Stock and final pricing are shown on the product page at checkout.

Frequently Asked Questions

Can Playwright run on a Linux server without a display?
Yes. Playwright runs browsers headless by default, so no desktop or display server is required on the VPS.
Why does the browser fail to launch on my VPS?
Usually missing system libraries. Run npx playwright install --with-deps, or use the official Playwright Docker image, which includes them.
How many parallel workers can I run?
Roughly one per vCore, if there is enough RAM for each browser. Reduce workers if tests time out or memory runs low.
Should I use Docker for Playwright?
It is convenient: the official image includes the browsers and dependencies. Match the image tag to your Playwright version and pass --ipc=host for Chromium.
How do I debug a failing test on a headless server?
Enable traces on retry, then open them with npx playwright show-trace. Traces include screenshots, DOM snapshots, network and console logs for every step.
Should end-to-end tests run against production?
Run the full suite against staging. Against production, run only safe, read-only smoke tests with dedicated test accounts.
How do I run Playwright from GitHub Actions on my VPS?
Register the VPS as a self-hosted runner, install browsers once, and add a workflow step that runs npx playwright test.
How do I stop flaky tests?
Use auto-waiting assertions instead of sleeps, isolate test data, avoid depending on test order, and fix tests that only pass on retry.
Can Playwright test mobile layouts?
Yes. Device presets emulate mobile viewport, user agent and touch, which covers responsive layouts; they do not replace testing on real devices entirely.
Which ServoMix plan suits a Playwright test server?
A 4 vCore / 16 GB AMD EPYC or Intel VPS runs about four parallel browser workers comfortably; choose 8 vCores / 32 GB for larger suites.

Frequently Asked Questions

Can Playwright run on a Linux server without a display?

Yes. Playwright runs browsers headless by default, so no desktop or display server is required on the VPS.

Why does the browser fail to launch on my VPS?

Usually missing system libraries. Run npx playwright install --with-deps , or use the official Playwright Docker image, which includes them.

How many parallel workers can I run?

Roughly one per vCore, if there is enough RAM for each browser. Reduce workers if tests time out or memory runs low.

Should I use Docker for Playwright?

It is convenient: the official image includes the browsers and dependencies. Match the image tag to your Playwright version and pass --ipc=host for Chromium.

How do I debug a failing test on a headless server?

Enable traces on retry, then open them with npx playwright show-trace . Traces include screenshots, DOM snapshots, network and console logs for every step.

Should end-to-end tests run against production?

Run the full suite against staging. Against production, run only safe, read-only smoke tests with dedicated test accounts.

How do I run Playwright from GitHub Actions on my VPS?

Register the VPS as a self-hosted runner, install browsers once, and add a workflow step that runs npx playwright test .

How do I stop flaky tests?

Use auto-waiting assertions instead of sleeps, isolate test data, avoid depending on test order, and fix tests that only pass on retry.

Can Playwright test mobile layouts?

Yes. Device presets emulate mobile viewport, user agent and touch, which covers responsive layouts; they do not replace testing on real devices entirely.

Which ServoMix plan suits a Playwright test server?

A 4 vCore / 16 GB AMD EPYC or Intel VPS runs about four parallel browser workers comfortably; choose 8 vCores / 32 GB for larger suites.

Was this article helpful?

Your feedback helps us continuously improve ServoMix guides.

Share this article

Know someone who may find this guide useful?

Run Playwright End-to-End Tests on a Linux VPS | ServoMix