npm install# Copy template
cp configs/.env.example configs/.env.local
# Edit with YOUR credentials
# IMPORTANT: You need a real test account on the contact list app!
# See AUTHENTICATION_SETUP.md for detailed instructions
nano configs/.env.localWhat to fill in:
USER_NAME=your_test_email@example.com # Email from your test account
PASS_WORD=your_test_password # Password from your test accountDon't have a test account yet? See
AUTHENTICATION_SETUP.mdfor step-by-step instructions on creating one.
# List available tests (uses local environment from npm script)
npm run test:api:local -- --list
# Expected output: ✓ Environment loaded: local
# ✓ Loaded configuration data...
# Total: 5 tests found# Run smoke tests only using npm script (includes ENV=local)
npm run test:api:local -- --grep "@smoke"
# Or run all API tests
npm run test:api:local
# Or run E2E tests
npm run test:e2e:local
# Or use direct npx command with environment variable
npx playwright test --grep "@smoke"# Generate and open Allure report
npx allure serve allure-resultstsconfig.json- TypeScript strict mode configurationconfigs/.env.example- Environment templateREADME_IMPROVED.md- Comprehensive documentationIMPROVEMENTS.md- Detailed improvement logTEST_PROJECT/API/tests/features/API_Feature_1/improved-contact-api.spec.ts- Best practices example
UTILS/loadenv.ts- Better error handlingconstants.ts- New test tags and enumsplaywright.config.ts- Configurable via environment.gitignore- Better securitypackage.json- Clean dependenciesUTILS/*- JSDoc comments added
| Command | Purpose |
|---|---|
npm install |
Install all dependencies |
npm run test:api:local |
Run all API tests (local env) |
npm run test:e2e:local |
Run all E2E tests (local env) |
npx playwright test --grep "@smoke" |
Run smoke tests only |
npx playwright test --grep "@smoke|@regression" |
Run multiple tags |
npx playwright test --headed |
Run with visible browser |
npx playwright test --debug |
Debug mode |
npx allure serve allure-results |
View test report |
ENV=staging npx playwright test --project=api_testing |
Run on staging environment |
Use these tags to organize and filter tests:
@smoke- Quick smoke tests@regression- Full regression suite@api- API tests@e2e- End-to-end tests@critical- Critical tests@slow- Long-running tests
Example:
# Run only API and smoke tests
npx playwright test --grep "@api|@smoke"
# Run regression tests excluding slow ones
npx playwright test --grep "@regression" --grep-invert "@slow".env.local # Your credentials
.env # Environment file
configs/.auth/ # Browser state
node_modules/ # Dependencies
allure-results/ # Test artifacts
test-results/ # Test reports
These are already in .gitignore ✓
.env.example # Template only
tsconfig.json # Configuration
playwright.config.ts # Settings
README_IMPROVED.md # Documentation
IMPROVEMENTS.md # Change log
TEST_PROJECT/ # Test code
UTILS/ # Helper code
PlaywrightTemplateForUIAndAPITesting/
├── configs/
│ ├── .env.example ← Copy this to .env.local
│ └── .env.local ← Add YOUR credentials here
├── TEST_PROJECT/
│ ├── API/
│ │ └── tests/features/ ← Your API tests
│ └── E2E/
│ └── tests/features/ ← Your E2E tests
├── UTILS/ ← Helper utilities
├── constants.ts ← Test enums & tags
├── playwright.config.ts ← Playwright settings
├── README_IMPROVED.md ← Full documentation
├── IMPROVEMENTS.md ← What changed
└── package.json ← Dependencies
# Solution: Create the file
cp configs/.env.example configs/.env.local
nano configs/.env.local # Add your credentials# Edit .env.local and fill in:
USER_NAME=your_username
PASS_WORD=your_password# Verify tags are correct
npx playwright test --grep "@smoke" # lowercase, no spaces
# List all tests to verify
npm run test:api:local -- --list# Reinstall browsers
npx playwright install
npx playwright install-deps- Full Documentation: See
README_IMPROVED.md - What Changed: See
IMPROVEMENTS.md - Test Example: See
TEST_PROJECT/API/tests/features/API_Feature_1/improved-contact-api.spec.ts - Constants: See
constants.tsfor all enums
Before running tests, verify:
- You have Node.js v18+ installed (
node -v) - Dependencies installed (
npm install) -
configs/.env.localexists with your credentials - You created account on https://thinking-tester-contact-list.herokuapp.com
-
.env.localhas your username and password - Tests are discoverable (
npm run test:api:local -- --list)
Run your first test:
npm run test:api:localView the results:
npx allure serve allure-resultsNeed help? Read README_IMPROVED.md for comprehensive documentation.