Playwright `package.json`
Playwright package.json¶
The package.json file defines your project’s metadata, dependencies, test scripts, and execution logic. It serves as the entry point for anyone working with or executing your automation framework.
{
"name": "ul_poc",
"type": "module",
"version": "1.0.0",
"description": "Test Automation Framework POC Project",
"main": "index.js",
"scripts": {
"summary": "playwright show-report reports\\playwright-report",
"test-all": "npx playwright test",
"test-stg": "npx cross-env NODE_ENV=stg playwright test",
"test-dev": "npx cross-env NODE_ENV=stg playwright test"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@playwright/test": "^1.50.1",
"@types/axios": "^0.14.4",
"@types/node": "^20.14.8",
"cross-env": "^7.0.3",
"dotenv": "^16.4.5",
"monocart-reporter": "^2.9.17",
"playwright-ctrf-json-reporter": "^0.0.19",
"xlsx": "^0.18.5"
}
}
🖥 scripts — Custom CLI Commands | Script | Command | Description | | --- | --- | --- | | summary | playwright show-report reports\\playwright-report | Opens the test report in HTML format (Windows path separator used) | | test-all | npx playwright test | Runs all tests using the default configuration | | test-stg | cross-env NODE_ENV=stg playwright test | Runs tests with staging environment variables | | test-dev | cross-env NODE_ENV=dev playwright dev (typo?) | Likely intended to use NODE_ENV=dev, but currently points to staging |
📦 devDependencies¶
These are development-only tools installed via npm install --save-dev:
| Package | Purpose |
|---|---|
@playwright/test | Main test runner and automation framework |
@types/axios, @types/node | Type definitions for TypeScript compatibility |
cross-env | Sets NODE_ENV in a cross-platform way (Windows/Linux/macOS) |
dotenv | Loads variables from .env into process.env |
xlsx | Parses and validates Excel files in tests |
monocart-reporter | Generates rich HTML reports for Playwright |
playwright-ctrf-json-reporter | Generates machine-readable JSON test results (e.g. for CI integrations) |
🧪 How to Use Scripts¶
Run All Tests¶
npm run test-all Run Tests for STG Environment: npm run test-stg Open Playwright HTML Report: npm run summary ✅ Example Script Additions "scripts": { ... "test:ui": "npx playwright test -g '@ui'", "test:api": "npx playwright test -g '@api'", "test:watch": "npx playwright test --watch" }