End-to-end tests written with Playwright and JavaScript. The framework uses the Page Object
Model, tagged suites (@smoke, @integration, @prod), four environments (dev, qa, staging, production), and
Monocart reports. It runs with Bun.
The sample suite tests the public OrangeHRM demo. All four environments point at that demo until real URLs are provided.
- Page Object Model: locators and actions live in
src/pages/. Assertions live in the specs. - Independent data: application data is in
src/data/, environment settings inconfig/environments/, and credentials only in environment variables. Each test starts from a clean browser state. - Tags:
@smoke(every pull request),@integration(nightly),@prod(safe for production). - Environments: select one with
TEST_ENV. Production is read-only: only@prodtests may run there. - Reports: everything is written under
reports/(Monocart, HTML, JUnit, traces). - Quality gates: Prettier, ESLint with Playwright rules, Husky pre-commit hooks, and CI.
Prerequisites: Bun 1.1 or later, Node.js 20 or later (Playwright runs on Node), and Git.
bun install
bunx playwright install chromium
cp .env.example .env # then set E2E_USERNAME and E2E_PASSWORD
bun run test:smoke
bun run report:monocart # open the reportOn Windows PowerShell, use copy .env.example .env.
flowchart LR
A["TEST_ENV and .env"] --> B["config/environments/[env].json"]
B --> C["playwright.config.js: baseURL, reporters, projects"]
C --> D{"Environment is production?"}
D -- "yes" --> E["Only @prod tests run"]
D -- "no" --> F["Tags select tests (--grep)"]
E --> G["setup project logs in"]
F --> G
G --> H["Specs run with saved session"]
H --> I["Reports written to reports/"]
Text alternative: the environment is chosen from TEST_ENV. Production limits the run to @prod tests. The setup
project logs in once and saves the session. The specs then run, and the reports are written to reports/.
| Environment | TEST_ENV |
Read-only | Tags that may run |
|---|---|---|---|
| Development | dev (default) |
no | @smoke, @integration, @prod |
| QA | qa |
no | @smoke, @integration, @prod |
| Staging | staging |
no | @smoke, @integration, @prod |
| Production | production |
yes | @prod only |
Tags:
@smoke: fast checks of core pages. Runs on every pull request.@integration: multi-step flows across pages. Runs nightly on QA and staging.@prod: read-only checks safe for production. A test can carry several tags, for example@smoke @prod.
| Command | What it does |
|---|---|
bun run test |
Run the full suite in the selected environment |
bun run test:smoke |
Run @smoke tests |
bun run test:integration |
Run @integration tests |
bun run test:prod |
Run @prod tests |
bun run test:dev |
Full suite with TEST_ENV=dev |
bun run test:qa |
Full suite with TEST_ENV=qa |
bun run test:staging |
Full suite with TEST_ENV=staging |
bun run test:production |
Full suite with TEST_ENV=production (only @prod runs) |
bun run test:headed |
Run with a visible browser |
bun run test:ci |
Clean reports/ and run the suite (used by CI) |
bun run lint / lint:fix |
ESLint, optionally with auto-fix |
bun run format / format:check |
Prettier, optionally check only |
bun run report:html |
Open the Playwright HTML report |
bun run report:monocart |
Open the Monocart report |
bun run clean |
Delete reports/ |
bun run sauce:check |
Validate the Sauce Labs configuration (.sauce/config.yml) |
bun run sauce:run |
Run on Sauce Labs with saucectl (see docs/sauce-labs.md) |
test:prod filters by the @prod tag. test:production selects the production environment. They are different:
TEST_ENV=production bun run test:prod combines both.
.
├── config/environments/ dev, qa, staging, production settings (base URL, read-only flag)
├── src/
│ ├── config/ environment loader, tag constants, shared paths
│ ├── data/ application routes and expected values
│ ├── fixtures/ Playwright fixtures and the production guard
│ ├── pages/ page objects (BasePage and one class per page)
│ └── reporters/ custom console reporter
├── tests/
│ ├── auth/ login setup and login page tests
│ ├── dashboard/ dashboard tests
│ └── admin/ admin user tests
├── scripts/ helper scripts (opens the Monocart report)
├── docs/ guardrails and test plans
├── playwright.config.js one config for every environment
├── .sauce/config.yml saucectl configuration for Sauce Labs
├── eslint.config.js lint rules
├── .github/workflows/ CI
└── reports/ generated output (git-ignored)
const { test, expect } = require("../../src/fixtures");
const { TAGS } = require("../../src/config/tags");
test.describe("Dashboard", () => {
test.beforeEach(async ({ dashboardPage }) => {
await dashboardPage.open();
});
test(
"Verify dashboard title and breadcrumb",
{ tag: [TAGS.SMOKE, TAGS.PROD] },
async ({ page, dashboardPage, testData }) => {
await expect(page).toHaveTitle(testData.dashboard.title);
await expect(dashboardPage.breadcrumb).toHaveText(testData.dashboard.breadcrumb);
}
);
});Rules: import test from src/fixtures, tag every test, keep assertions in the spec, and never use fixed sleeps.
All output goes under reports/:
| Output | Location |
|---|---|
| Monocart report | reports/monocart/index.html (open with bun run report:monocart) |
| Playwright HTML report | reports/html/ (open with bun run report:html) |
| JUnit XML (CI) | reports/junit/results.xml |
| Traces and screenshots | reports/test-results/ |
| Workflow | When | Environment | Runs |
|---|---|---|---|
ci.yml |
every pull request and push to main |
dev (smoke) |
format check and lint in parallel, then @smoke, then CI |
nightly.yml |
02:00 UTC daily, or on demand | qa, staging |
@smoke and @integration |
prod-smoke.yml |
weekdays 06:00 UTC, or on demand | production |
@prod only (read-only) |
The CI workflow shows each stage as its own job. The aggregate CI check is the one branch protection requires.
Each run writes a summary table and uploads reports/. See docs/ci-cd.md.
Each job uses a GitHub Environment, so E2E_USERNAME and E2E_PASSWORD are scoped per environment. Reports are
uploaded as artifacts. Setup steps, secrets, and branch protection are in docs/ci-cd.md.
The full guides are in docs/:
- Getting started and troubleshooting
- Architecture, environments, and tagging
- Writing tests and test data
- Reporting, CI/CD, and guardrails
- Architecture decisions
Read AGENTS.md before making changes. Keep pull requests small, and update this README and the relevant doc in the same pull request as any change to scripts, environments, tags, or quality gates.
MIT. See LICENSE.