8. Node.js & npm Environment for Playwright

Node.js & package.json in Test Projects

{
  "name": "playwright-automation",
  "version": "1.0.0",
  "type": "module",
  "scripts": {
    "test": "playwright test",
    "test:headed": "playwright test --headed",
    "test:ui": "playwright test --ui",
    "report": "playwright show-report"
  },
  "devDependencies": {
    "@playwright/test": "^1.49.0",
    "dotenv": "^16.4.5"
  }
}

Environment Variables (.env)

BASE_URL=https://staging.targetqa.com
HEADLESS=true

Task

  • Implement getEnvironmentConfig:
  • 1. Accept env object containing BASE_URL and HEADLESS.
  • 2. Return { baseUrl: env.BASE_URL ?? "https://targetqa.com", headless: env.HEADLESS === "true" }.
πŸ’‘Common doubts
Did you like the problem?
Lesson 8 of 35
JavaScript
Loading code editor…
Next