Objective: Read the two files that run every generated project — package.json, the ID card and remote control, and playwright.config, the runner's rulebook — and make your first two safe edits: add a script, and repoint the suite.
⏱ ≈45 min full lesson · English edition — Español · العربية · বাংলা in translation
Every Playwright project you will ever open — generated by TestGen or written by a team — is run by the same two files. package.json says what the project is and which commands it understands. playwright.config.ts says how the test runner runs the tests. You met both in Lesson 23, when you set up your first project. This lesson teaches you to actually read them, because everything you will ever do in a suite goes through one of these two doors.
package.json is the project's ID card. Open your downloaded suite and read the top of it. The name is example-com-regression-suite. The version is 1.0.0. private: true means the project is yours alone — it can never be published to a registry by accident. And the description says what the suite is: a generated Playwright regression suite for example.com, written in Page Object Model style. Name, version, description: what is this, whose is it, what does it do.
Below that sits the section you will touch most: scripts — the project's remote control. Every command you type is a button defined in this file. npm test is not a Playwright feature and not an npm feature; it is this project saying: when someone presses test, run playwright test with the Desktop Chrome project. Your suite's real buttons: test (Desktop Chrome only), test:all (every project), report (opens the results dashboard), results:excel (the last run as a spreadsheet), results:push (results posted to Jira or Trello), dashboard (the results server), and a few specialists like test:ui and auth:capture. When a teammate says “just run the dashboard”, a line in this file is what they mean.
The last section of the ID card is the parts list: dependencies and devDependencies — the pieces the project needs, with the versions it accepts. Your suite lists three: @playwright/test, the runner itself; @types/node, so the editor understands Node; and typescript. The little hat in ^1.48.0 matters: it means “this version, or a newer compatible one” — and when this suite was installed, that range resolved to Playwright 1.65.1. The parts themselves live in the node_modules folder: real machinery, thousands of files, and the one folder you never edit. If it ever looks broken, delete it and run npm install — it is rebuilt from the parts list, exactly.
playwright.config.ts is the runner's rulebook. At postcard depth it answers four questions. Where do the tests live? testDir — the tests folder, and only there. How long does a test get? Sixty seconds per test, and eight seconds for a single check to become true. What gets saved when a test fails? A screenshot of the failure, and a trace — a recording you can replay step by step. And which site, and which browser? The base address — example.com in the generated suite — and five projects: Desktop Chrome, Firefox, Safari, an iPhone 15, and a Pixel 7.
Two edits make both files yours. First, add a button: a new line in scripts that runs only the smoke file, so npm run smoke becomes the quick check you press all day. Second, repoint the suite: the config's baseURL line reads the TESTGEN_BASE_URL environment variable, or — if nobody set one — the address written after it. Change that written address, re-run, and every relative address in every test resolves against the new site. Some checks will fail there, and that failure is the proof the suite really moved.