The suite runs against one environment per run. The environment is chosen with TEST_ENV. Each environment has a
settings file in config/environments/.
| Environment | TEST_ENV |
Settings file | Read-only |
|---|---|---|---|
| Development | dev (default) |
config/environments/dev.json |
no |
| QA | qa |
config/environments/qa.json |
no |
| Staging | staging |
config/environments/staging.json |
no |
| Production | production |
config/environments/production.json |
yes |
Current state: all four files point at the OrangeHRM demo as placeholders. Replace each
baseUrlwith the real URL when it is available.
{
"name": "qa",
"description": "QA environment. Placeholder: points at the OrangeHRM demo until a real QA URL is provided.",
"baseUrl": "https://opensource-demo.orangehrmlive.com",
"readOnly": false
}| Key | Type | Meaning |
|---|---|---|
name |
string | must match the file name and an entry in SUPPORTED_ENVIRONMENTS |
description |
string | shown to humans only |
baseUrl |
string (absolute URL) | the base for every page.goto and env.url(...) call |
readOnly |
boolean | true limits the run to @prod tests and makes the guard enforce it |
Settings files hold no secrets. Credentials come from environment variables.
BASE_URL(environment variable) overridesbaseUrlin the settings file.TEST_ENVselects the file. Unset meansdev.- An unknown
TEST_ENVfails before any test starts, with the list of valid names.
TEST_ENV=qa bun run test:smoke
TEST_ENV=staging BASE_URL=https://staging.example.test bun run test:integrationProduction is protected in three layers. Each one works without the others.
flowchart TD
START["TEST_ENV=production"] --> CFG{"readOnly is true?"}
CFG -- "yes" --> GREP["playwright.config.js: grep /@prod/"]
GREP --> SEL["Only @prod tests are selected"]
SEL --> GUARD{"Fixture guard: test tagged @prod or setup project?"}
GUARD -- "yes" --> RUN["Test runs"]
GUARD -- "no" --> FAIL["Test fails before it starts, with a clear message"]
CHG["Config filter removed or changed"] --> GUARD
Text alternative: in production, the config selects only @prod tests. The fixture guard checks every test that starts,
and fails any test that is not tagged @prod and is not in the setup project. The guard is a backup for the config
filter: it applies if that filter is removed or changed.
- Config filter:
playwright.config.jssetsgrep: /@prod/whenreadOnlyis true. A--grepon the command line is combined with this filter, so it can only narrow the selection. It cannot select a non-@prodtest. - Fixture guard:
src/fixtures/index.jsruns for every test. It refuses any test in a read-only environment unless the test is tagged@prod(or belongs to the setup project). It is a backup for the config filter. - Test rules:
@prodtests must be read-only. See tagging.
- Create
config/environments/<name>.jsonwith the four keys above. - Add the name to
SUPPORTED_ENVIRONMENTSinsrc/config/environment.js. - Optionally add a script to
package.json, for example"test:<name>": "cross-env TEST_ENV=<name> playwright test". - Add a GitHub Environment and its secrets, then reference it from a workflow. See CI/CD.
- Update the environment table in this file and in the project README.
| Where | Used for |
|---|---|
.env on your machine (git-ignored) |
local runs |
| GitHub Environment secrets | CI runs (E2E_USERNAME, E2E_PASSWORD) |
Never put a password in a settings file, a test, or the .env.example template.