NPM Script and CLI | Bondar Academy
Course: Playwright UI Testing with TypeScript
Module: Advanced Tricks and Techniques
Instructor: Artem Bondar
Lesson Summary
This lesson focuses on custom NPM scripts , which help organize terminal commands into more manageable components. NPM scripts can run other scripts in parallel or sequentially , making them useful for tasks such as running tests in a CI/CD environment. Key Concepts Command Line Interface (CLI) : The lesson uses the PW practice app to demonstrate how to run tests using CLI commands. Running Tests : To run a specific test file, use the command: npx playwright test use-page-objects.spec.ts To specify a browser, add --project=Chromium or --project=Firefox . Defining NPM Scripts : Scripts are defined in the package.json file under the scripts section. For example: "scripts": { "page-objects-chrome": "npx playwright test --project=Chromium use-page-objects.spec.ts", "page-objects-firefox": "npx playwright test --project=Firefox use-page-objects.spec.ts" } Executing Scripts Run a script using: npm run script-name . To run multiple scripts sequentially, use && : npm run page-objects-chrome && npm run page-objects-firefox To run scripts in parallel, use & : npm run page-objects-chrome & npm run page-objects-firefox In summary, NPM scripts provide a convenient way to manage and execute terminal commands, enhancing productivity and reducing errors in command entry.