Skip to content

About

Playwright Web & API Automation in Nodejs/TypeScript

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

Playwright Framework with TypeScript/Nodejs

Sample project to demonstrate Tests written with Playwright with TypeScript.

Pre-requirements

  • Git(I've used version 2.56.1 while writing this doc)
  • Node.js (I've used version v24 while writing this doc)
  • Visual Studio Code(I've used version Stable Build while writing this doc)
  • Playwright Extension(Install the official extension in the Visual Studio Code)

Installation

To clone and run this project, you will need:

A terminal or command prompt to run the commands

git clone <repository_url>

Navigate into the cloned project directory:

cd <project_directory>

Install system dependencies with the following command:

npm install

Install Playwright browsers and OS dependencies with the following command:

npx playwright install --with-deps

Test Files Overview

Check it out the following test files:

  • .\tests\accessibility_test.spec.ts - Accessibility testing
  • .\tests\api_test.spec.ts - API testing
  • .\tests\visual_test.spec.ts - Visual testing
  • .\tests\web_test.spec.ts - Web testing

Project Structure: Page Object Model and Single Responsability Principle Pattern

Package Responsibility
data responsible for managing test data
locators responsible for identifying web elements
pages responsible for page actions (navigation, (fills, types), clicks, etc.)
playwright.config.ts responsible for configuring the Playwright test runner
tests responsible for executing the test suite
playwright-report responsible for storing the test reports generated by Playwright
test-results responsible for storing the test results generated by Playwright

Running the tests

Inside that directory, you can run several commands:

Updates the snapshots for visual tests.

npx playwright test tests/visual/visual.spec.ts --update-snapshots

Runs the tests for the web project.

npx playwright test --project=web

Runs the tests for the API project.

npx playwright test --project=api

Runs the tests for the visual project.

npx playwright test --project=visual

Runs the tests for the accessibility project.

npx playwright test --project=accessibility

Starts the interactive UI mode.

npx playwright test --ui

Runs the tests in debug mode.

npx playwright test --debug

Generates test code using the Codegen tool.

npx playwright codegen

Runs all the tests.

npx playwright test

Show Status Report

To see the status report, you can run the command:

npx playwright show-report

About

Playwright Web & API Automation in Nodejs/TypeScript

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages