|

Day 28 of 100: npm and package.json — Managing Your Test Project

Day 28 of 100 — 100 Days of Playwright with TypeScript Challenge. Phase: JavaScript Fundamentals. JavaScript (Days 1-33) → TypeScript (Days 34-63) → Playwright (Days 64-96) → AI Framework Capstone (Days 97-100).

🎭 Want to master this with real projects? Join the Playwright Automation Mastery course at The Testing Academy.


package.json defines your project: dependencies, scripts, metadata. npm manages it all.

Contents

The Essential Commands

npm init -y                        # create package.json
npm install @playwright/test -D    # -D = devDependency
npm install                        # restore from lockfile
npm ci                             # clean install — USE IN CI
npm run test                       # run a script
npm outdated                       # check stale deps

🚀 Level Up Your Playwright

From locators to CI pipelines — build a production-grade Playwright + TypeScript framework step by step.

package.json for a Test Project

{
  "name": "qa-framework",
  "scripts": {
    "test": "playwright test",
    "test:smoke": "playwright test --grep @smoke",
    "test:headed": "playwright test --headed",
    "report": "playwright show-report"
  },
  "devDependencies": {
    "@playwright/test": "^1.49.0",
    "@faker-js/faker": "^9.0.0"
  }
}

Versioning and the Lockfile

  • ^1.49.0 = any 1.x.x ≥ 1.49.0 — minor updates allowed
  • ~1.49.0 = patch updates only
  • package-lock.json pins exact versions — ALWAYS commit it
  • npm ci installs exactly from lockfile — reproducible CI builds

Tomorrow (Day 29): Regex — pattern matching for testers.

🎓 Master Playwright End to End

Join hundreds of SDETs building real automation frameworks. Lifetime access, hands-on projects, and a job-ready portfolio.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.