JavaScript
Playwright + web app
Build the app, start API and frontend as services, run the browser tests against them โ traces and screenshots are kept with the run.
This guide shows:
- Two process services with HTTP readiness checks
- Random ports flow into the app config and into
BASE_URL - Reports, screenshots and traces collected as
artifacts retryfor the notoriously flaky browser layer
version: 0
name: playwright-web
ports:
web: random
api: random
test:
name: e2e
sequence:
- name: install
command: npm ci --no-audit --no-fund
inputs: [package-lock.json]
- name: build
command: npm run build
inputs:
- src/**
- package-lock.json
- vite.config.ts
- name: browser tests
# both processes are dependencies of this test: the runner starts
# them, waits until they answer, and stops them afterwards
services:
api:
command: npm run start:api
env:
PORT: ${{ ports.api }}
ready:
http: http://127.0.0.1:${{ ports.api }}/healthz
timeout: 60s
web:
command: npm run preview -- --port ${{ ports.web }}
env:
API_URL: http://127.0.0.1:${{ ports.api }}
ready:
http: http://127.0.0.1:${{ ports.web }}
timeout: 60s
env:
BASE_URL: http://127.0.0.1:${{ ports.web }}
command: npx playwright test
# traces and screenshots are kept with the run, also when it fails
artifacts:
- playwright-report/**
- test-results/**/*.png
- test-results/**/trace.zip
retry:
count: 2
delay: 2s
Browse this example on GitHub โ
Copy it into your project, adjust the commands, run testfile start. Missing your
stack? Open an issue โ or
start from Getting started and let
testfile init write a first version for you.