Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/edumserrano/playwright-adventures

Playwright demos and tips such as how to run in docker, how to get code coverage, etc
https://github.com/edumserrano/playwright-adventures

accessibility code-coverage docker monocart-reporter playwright playwright-fixtures screenshots visual-regression-testing

Last synced: about 22 hours ago
JSON representation

Playwright demos and tips such as how to run in docker, how to get code coverage, etc

Awesome Lists containing this project

README

        

# Playwright adventures

[![Build and test the demo apps](https://github.com/edumserrano/playwright-adventures/actions/workflows/build-test-demos.yml/badge.svg)](https://github.com/edumserrano/playwright-adventures/actions/workflows/build-test-demos.yml)
[![Markdown link check](https://github.com/edumserrano/playwright-adventures/actions/workflows/markdown-link-check.yml/badge.svg)](https://github.com/edumserrano/playwright-adventures/actions/workflows/markdown-link-check.yml)
[![Prettier check](https://github.com/edumserrano/playwright-adventures/actions/workflows/prettier-check.yml/badge.svg)](https://github.com/edumserrano/playwright-adventures/actions/workflows/prettier-check.yml)

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)
[![GitHub Sponsors](https://img.shields.io/github/sponsors/edumserrano)](https://github.com/sponsors/edumserrano)
[![LinkedIn](https://img.shields.io/badge/LinkedIn-Eduardo%20Serrano-blue.svg)](https://www.linkedin.com/in/eduardomserrano/)

- [Description](#description)
- [Playwright demos](#playwright-demos)
- [Tips](#tips)
- [Learn more about Playwright](#learn-more-about-playwright)

## Description

**[Playwright](https://playwright.dev/) enables reliable end-to-end testing for modern web apps and it has become my preferred approach to test web apps.** This repo aims to consolidate and share some of the experiences I've had and the solutions I've come up with whilst using Playwright.

My experiences with Playwright focused on using it as the test tool whilst developing web apps, where the main goal was to get better tests, including Visual Regression and Accessibility tests, which could run on a developer's machine as part of their development loop as well as run as part of the build pipeline of the web app, before the app is even deployed to an environment.

> [!IMPORTANT]
>
> Although the code demos presented here use Angular for the target app of the Playwright tests, the Playwright concepts that are demoed are frontend framework agnostic which means they and can be applied to any frontend framework.

## Playwright demos

| Demo | Description |
| :---------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [code-coverage-with-monocart-reporter](/demos/code-coverage-with-monocart-reporter/README.md) | Playwright code coverage using [monocart-reporter](https://github.com/cenfun/monocart-reporter). |
| [code-coverage-with-istanbul-via-webpack-babel-plugin](/demos/code-coverage-with-istanbul-via-webpack-babel-plugin/README.md) | Playwright code coverage using [Istanbul via Webpack Babel plugin](https://github.com/istanbuljs/babel-plugin-istanbul). |
| [docker](/demos/docker/README.md) | Run Playwright tests in Docker. Also shows how to use Playwright tests UI mode in Docker. Especially helpful to eliminate screenshot differences when running the tests across different Operating Systems. For instance, if you develop in Windows but your CI runs on Linux. |
| [stale-screenshots-cleanup](/demos/stale-screenshots-cleanup/README.md) | Delete stale Playwright test screenshots. |
| [fixtures](/demos/fixtures/README.md) | Shows useful Playwright fixtures you can reuse:
- [time/date emulation](/demos/fixtures/README.md#timedate-emulation): so that you can do reliable asserts on screenshots or text that contains time/date information;
- [capture console messages](/demos/fixtures/README.md#capture-console-messages): so that you can assert on console messages.
- [fail tests upon unexpected console messages](/demos/fixtures/README.md#fail-tests-upon-unexpected-console-messages): allows you to define allowed console messages and will fail the tests if any unexpected console message is produced. Good to catch left over debug/temp console messages.
- [capture page error](/demos/fixtures/README.md#capture-page-errors): so that you can assert on uncaught exceptions.
- [fail tests on page errors](/demos/fixtures/README.md#fail-tests-on-page-errors): fails tests if any uncaught exception is produced.
- [project name](/demos/fixtures/README.md#project-name): allows you to control test behaviour depending on the Playwright project.
- [annotations](/demos/fixtures/README.md#custom-annotations): shows how to add custom annotations to tests. |
| [monocart-reporter-advanced-config](/demos/monocart-reporter-advanced-config/README.md) | Shows some advanced features of the [monocart-reporter](https://github.com/cenfun/monocart-reporter) HTML report:
- [add report metadata.](/demos/monocart-reporter-advanced-config/README.md#add-report-metadata)
- [customize the style of test tag.](/demos/monocart-reporter-advanced-config/README.md#customize-the-style-of-test-tags)
- [automatically collect test comments and add them to the test report.](/demos/monocart-reporter-advanced-config/README.md#automatically-collect-test-comments-and-add-them-to-the-test-report) |
| [accessibility-axe](/demos/accessibility-axe/README.md) | How to use Playwright for [accessiblity testing](https://playwright.dev/docs/accessibility-testing) using the [@axe-core/playwright](https://www.npmjs.com/package/@axe-core/playwright) npm package. |
| [accessibility-lighthouse](/demos/accessibility-lighthouse/README.md) | How to use [lighthouse](https://www.npmjs.com/package/lighthouse) with Playwright for accessiblity, SEO, performance and best-practices recommendations. |

## Tips

- [Which code coverage should I use with Playwright? monocart-reporter or Istanbul with Webpack Babel plugin?](/docs/tips.md#which-code-coverage-should-i-use-with-playwright-monocart-reporter-or-istanbul-with-webpack-babel-plugin)
- [How to debug Playwright tests](/docs/tips.md#how-to-debug-playwright-tests)
- [Should you use Git LFS when you use screenshots?](/docs/tips.md#should-you-use-git-lfs-when-you-use-screenshots)
- [The `webServer.reuseExistingServer` configuration option](/docs/tips.md#the-webserverreuseexistingserver-configuration-option)
- [Which reporters should I use?](/docs/tips.md#which-reporters-should-i-use)
- [Limit reporters when running in UI mode](/docs/tips.md#limit-reporters-when-running-in-ui-mode)
- [Add start up logs](/docs/tips.md#add-start-up-logs)
- [You might not need to run all your tests against all your projects](/docs/tips.md#you-might-not-need-to-run-all-your-tests-against-all-your-projects)
- [Avoid using watch mode on the target test apps](/docs/tips.md#avoid-using-watch-mode-on-the-target-test-apps)
- [What are the available devices for test projects configuration?](/docs/tips.md#what-are-the-available-devices-for-test-projects-configuration)
- [Use test parallelization even on CI](/docs/tips.md#use-test-parallelization-even-on-ci)
- [Set the filepath for screenshots](/docs/tips.md#set-the-filepath-for-screenshots)
- [webServer.url: beware of `localhost` vs `127.0.0.1` when using Node](/docs/tips.md#webserverurl-beware-of-localhost-vs-127001-when-using-node)
- [You can inject test only code into your app with `page.addInitScript`](/docs/tips.md#you-can-inject-test-only-code-into-your-app-with-pageaddinitscript)
- [Beware of font kerning/CSS issues with Visual Regression Tests](/docs//tips.md#beware-of-font-kerningcss-issues-with-visual-regression-tests)

## Learn more about Playwright

- [Playwright docs](https://playwright.dev/docs/intro): official documentation.
- [Playwright API reference](https://playwright.dev/docs/api/class-playwright): official API reference.
- [Playwright's Discord channel](https://discord.com/servers/playwright-807756831384403968): great for interacting with community members and asking questions.
- [Playwright's GitHub issues](https://github.com/microsoft/playwright/issues): always worth searching through when you're trying to learn new concepts or in case others have faced some problem you might be facing.
- [Playwright's YoutTube channel](https://www.youtube.com/@Playwrightdev): small sized videos about what's new with each Playwright release. Great way to keep up to date.
- [Learn Playwright - Resources for learning end-to-end testing using Playwright automation framework](https://ray.run/): great curated collection of Playwright resources. From blogs, to FAQS, to videos, etc.
- [Adrian Maciuc's blog](https://blog.martioli.com/): blog with lots of Playwright related posts.
- [CommitQuality Playwright's YouTube Playlist](https://www.youtube.com/playlist?list=PLXgRgGX8-5UVm9yioRY329rfcfy3MusiY): small sized tutorials that will help you master Playwright.
- [Playwright Solutions](https://playwrightsolutions.com/): Curated Selection of Playwright Automated Test Problems and Solutions.
- [Awesome Playwright](https://github.com/mxschmitt/awesome-playwright): A curated list of awesome tools, utils and projects using Playwright.
- [Using Playwright Test to run Unit Tests](https://pkerschbaum.com/blog/using-playwright-to-run-unit-tests): good explanation of why you should use Playwright even for unit tests.
- [25 reasons to choose Playwright as your next web testing framework](https://marcusfelling.com/blog/2022/25-reasons-to-choose-playwright-as-your-next-web-testing-framework/)