vasu-playwright-cli
v1.7.1
Published
Playwright TypeScript CLI to initialize/update with sample Playwright tests, framework setup and utilities
Downloads
41
Maintainers
Readme
Playwright TypeScript CLI
| | | | | | [email protected] | | :-------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------: |
About
playwright-ts-cli
is a powerful command-line tool designed to initialize and update projects with the Playwright TypeScript template. It simplifies the process of setting up a new project with specific configurations, dependencies, and structure, allowing developers to kickstart their Playwright testing with ease.
Features
- Initialize Project: Quickly scaffold a new project with predefined Playwright TypeScript configurations, dependencies, and structure.
- Update Project: Seamlessly update existing projects with the latest files and configurations from the Playwright TypeScript template.
- Compatibility: Works with the vasu-playwright-utils library, offering additional utilities and functionalities.
Prerequisites
Ensure you have the following software installed on your machine:
- npm (v8.0.0 or later): Package manager for JavaScript, used to install and manage software packages.
- To verify your current version, use the command
npm -v
. - If npm isn't installed, follow the npm installation guide.
- To verify your current version, use the command
- Node.js (v16.0.0 or later): JavaScript runtime built on Chrome's V8 JavaScript engine, allowing the execution of JavaScript server-side.
- To verify your current version, use the command
node -v
.
- To verify your current version, use the command
- Git: Distributed version control system used to track changes in source code during software development.
- To check if Git is installed, run the command
git --version
. - If Git isn't installed, download and install it from the official Git website.
- To check if Git is installed, run the command
Installation
1. Install Node.js
Before installing the CLI, make sure to have Node.js installed on your system. Here are two ways to install Node.js:
Using Official Website:
- Visit the official Node.js website.
- Download and install the latest stable version.
Using Command Line (nvm):
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash source ~/.nvm/nvm.sh nvm install --lts
2. Create a Playwright Test Directory
mkdir playwright-e2e-tests
cd playwright-e2e-tests
3. Install vasu-playwright-cli
npm i -D vasu-playwright-cli
Usage
Initialize a New Project
Navigate to the desired directory and run:
npx vasu-playwright-cli init
This command will set up a new project with ready to use Playwright TypeScript framework, including:
- Setup the Playwright TypeScript framework template with sample tests.
- Create a new
package.json
file with all the necessary dependencies. - Initializing a new Git repository if neither the current nor parent directory is a Git repository.
- Installing all the npm packages including the playwright utils library which contains playwright helper methods.
Update an Existing Project with future updates
Navigate to the project directory and run:
npx vasu-playwright-cli update
This command will update specific files or directories within the project, aligning them with the latest updates to the Playwright TypeScript template.
Update Playwright Library
Keep your Playwright library up to date with the latest playwright utilities which contain the helper methods that are updated regularly:
npm i -D vasu-playwright-utils@latest
Running Tests
To make sure the project framework is working as expected, you can run the following command to run the sample tests:
npm run test:chromium-headed -- sauce-demo-all-pass.spec.ts
View the report with:
npx playwright show-report
Issues and Feedback
If you encounter any issues or have feedback, please Raise an Issue on GitHub.
Contributing
We welcome contributions! Feel free to submit a Pull Request on GitHub.
License
This project is licensed under the MIT License. See the LICENSE file for details.