Skip to content

Playwright how to: setup mobile layout tests, command to run single test, login once by reusing context, gremlin.js

Notifications You must be signed in to change notification settings

davidseow/how-to-playwright

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

how-to-playwright

Example Playwright test setup for test runners listed below.

  • jest-playwright
  • @playwright/test

Checks are written against React Admin demo and will include the following

  • screenshot on test failure
  • example tests
  • example mobile layout tests (added for @playwright/test)
  • example test that manipulates network requests
  • login once by reusing context (added for @playwright/test)
  • example command to run a single test
  • Monkey testing with Gremlin.js
  • Fullscreen capture on test failure
  • Override/extend test fixtures
  • Page Object with custom type
  • Enable trace recording for a test block

Setup

Uses pnpm instead of npm. Please see pnpm installation guide to set this up.

Access test runner sub-folder (e.g. ./jest-playwright or ./playwright-test). And run pnpm i to install node dependencies.

To trigger checks, just run pnpm t.

If you would like to run checks in headed mode, pnpm test:watch (only in jest-playwright)

To run against a single check/checks grouped within a describe block, pnpm t -- --grep '<describe label|test label>'. E.g.: pnpm t -- --grep 'Customers'

Troubleshooting

macOS firewall popup on every debug run

With every debug run (in headed mode), you get prompted the following question - "Do you want to the application Chromium.app to accept incoming network connections?". Explanation is documented in link

tldr; you can resolve this by running the following command

sudo codesign --force --deep --sign -  ~/Library/Caches/ms-playwright/chromium-*/chrome-mac/Chromium.app

About

Playwright how to: setup mobile layout tests, command to run single test, login once by reusing context, gremlin.js

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published