Skip to content

jeevan-p-gowda/playwright-template

Repository files navigation

playwright-template

Playwright TS TypeScript Node Chromium Yarn Jenkins CI License: MIT

This repository provides a template for getting started with building a Playwright framework. It includes a pre-configured setup for writing, running, and managing end-to-end tests for web applications.

🧩Application

E-Commerce - Website

Swagger

Postman publish

Postman collection. Import the downloaded JSON into Postman.

🏗️Pre-requisite

  1. TypeScript foundations and beyond.
  2. Playwright.

🛠️Setup

  1. Install Git
    1. For Windows - Install Git Bash
    2. For MacOS X
      1. Install brew by executing /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
      2. Install git - brew install git
  2. Install NodeJS >=18 - based on your platform
  3. Run git clone - to clone the repo
  4. Install Cursor an AI coding agent and open the cloned repo
  5. Install recommended VS code extensions
  6. Run make setup - install all dependencies.
  7. In folder 📁.env create <env_file_name>.env file containing variables of app which has to be maintained as a secret. Below is the example,
    BASE_URL=https://web-playground.ultralesson.com/account/login
    EMAIL=xxxx@gmail.com
    PASSWORD=Xxxx@xx24

Caution

Do not hardcode any sensitive information

⏯️Execution

ENV=<env_file_name> yarn playwright test <relative_path_to_test_file>

Warning

If using Windows, set IDE terminal to Git Bash and execute.

🧬Features

  • Reporting: Utilized native playwright html report, view by executing yarn playwright show-report.
  • Debugging: follow steps mentioned here.

♾️CI

Follow one of the below examples to configure CI.

  1. Jenkins - Create a pipeline as per required style, map the Jenkinsfile in build config.
  2. Github Actions - .yml will reflect automatically in Actions when pushed.

Important

Install all plugins for Jenkins mentioned in Jenkinsfile comments. Delete .yml if using different CI tool other than Github Actions.

🧑🏻‍🦯Guide

  • Follow this for different commands to run tests.
  • Refer this for contributing.

🔨Troubleshoot

  1. If you encounter any dependency issues, follow these steps:
    1. Delete the node_modules folder and the yarn.lock file.
    2. Run yarn to install the dependencies.
  2. In Windows
    1. if you get nodejs permission issue
      1. Navigate to C:\Program Files\nodejs
      2. Right click on nodejs folder and click on Properties
      3. Go to Security tab and click Edit
      4. Click on Users(hostname of your PC) and check Full control permission for Allow
      5. Click on Apply and OK
    2. if you get EPERM: operation not permitted" on Windows with npm
      1. Open .npmrc file by executing npm config edit in terminal or manually with any text editor.
      2. Change prefix variable to C:\Users\<User Name>\AppData\Roaming\npm

Tip

Upgrade playwright with yarn up @playwright/test Set yarn latest stable version with yarn set version stable

About

Playwright with typescript template for creating robust AI-first test automation framework.

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors