npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

playwright-json-summary-reporter-fork

v1.1.0-17

Published

A Simple Playwright Reporter

Downloads

64

Readme

playwright-json-summary-reporter-fork

npm (scoped)

This package can be installed to generate a simple summary.json file that can be used as apart of a Playwright Test automation framework. My main use case for building this is to have quick access to a list of failed or succeeded tests for re-running failures (outside of playwright's retry functionality). I also use this as a way to quickly identify if all tests passed within a github action.

Install

npm install [email protected] --save-dev

Usage

Modify your playwright.config.ts file to include the reporter:

  reporter: [
    ['playwright-json-summary-reporter-fork'],
    ['html'], // other reporters
    ['dot']
  ],

Now when you run a test there should be a new file summary.json that gets saved to the root of the directory. An example of the file is shown below.

{
  "tests": [
    {
      "testPath": "tests/main_page/main_page.spec.ts:12:9",
      "project": "iPhone 12",
      "testTitle": "visual main  page",
      "status": "failed"
    },
    {
      "testPath": "tests/media/meetups_page.spec.ts:19:9",
      "project": "iPhone 12",
      "testTitle": "visual meetups  page",
      "status": "passed"
    }
  ]
}

Пример makefile-а для использования в CI с рераном только упавших тестов из summary.json

build-playwright-image:
	docker buildx build --platform linux/amd64,linux/arm64 --tag harbor.kolesa-team.org/utils/playwright:latest --file ./tests/e2e/Dockerfile . && \
	docker push harbor.kolesa-team.org/utils/playwright:latest

# Парсинг флагов командной строки
flags:
	while [ $$# -gt 0 ]; do \
		case "$$1" in \
			--config=*) config=$${1#*=}; shift;; \
			--run=*) run=$${1#*=}; shift;; \
			-u) shift; update_snapshots=-u; shift;; \
			--headed) headed=$$1; shift;; \
			--shard*) shard=--shard=$${1#*=}; shift;; \
			--grep=*) grep=$${1#*=}; shift;; \
			--projects=*) projects=$${1#*=}; shift;; \
			*) echo "Unknown option: $$1" >&2; exit 1;; \
		esac; \
	done

playwright_docker_run_base := docker run --rm \
	-e FAILED_TESTS="$$(jq -r ".tests | map(select(.status == \"failed\")) | .[].testPath" ./summary.json | tr "\n" " ")" \
	-e TEST_TITLES="$$(jq -r '.tests | map(select(.status == "failed")) | map(.testTitle) | unique | join("|")' ./summary.json)" \
	-e UNIQUE_PROJECTS="$$(jq -r '.tests | map(select(.status == "failed")) | map(.project) | unique | join(",")' ./summary.json)" \
	--volume $$(pwd):/code \
	--user root \
	--workdir /code \
	--ipc=host \

ci_docker_run := $(playwright_docker_run_base) \
	-e IS_CI=true \
	harbor.kolesa-team.org/utils/playwright:latest \

# make playwright-ci -- run="npx playwright test" config=--config=./tests/e2e/playwright.config.ts grep='-g "visual main  page|visual meetups  page"' projects='--project="iPhone 12"'
playwright-ci: flags
	$(ci_docker_run) bash -c '\
		echo "FAILED_TESTS: $${FAILED_TESTS}"; \
		echo "TEST_TITLES: $${TEST_TITLES}"; \
		echo "UNIQUE_PROJECTS: $${UNIQUE_PROJECTS}"; \
		if [ -n "$${FAILED_TESTS}" ]; then \
			projects_args=(); \
			IFS=","; \
			projects_array=($${UNIQUE_PROJECTS}); \
			for project in $${projects_array[@]}; do \
				projects_args+=("--project=$${project}"); \
			done; \
			echo "$(run) $(config) ${update_snapshots} $${projects_args[@]} -g $${TEST_TITLES}"; \
			$(run) $(config) ${update_snapshots} $${projects_args[@]} -g $${TEST_TITLES}; \
		else \
			echo "$(run) $(config) ${update_snapshots} ${shard} ${grep} ${projects}"; \
			$(run) $(config) ${update_snapshots} ${shard} ${grep} ${projects}; \
		fi'

# make playwright-docker-local -- run="npx playwright test" config=--config=./tests/e2e/playwright.config.ts grep='-g "visual main  page|visual meetups  page"' projects='--project="iPhone 12"' headed=--headed
playwright-docker-local: flags
	$(local_docker_run) bash -c '\
		echo "FAILED_TESTS: $${FAILED_TESTS}"; \
		echo "TEST_TITLES: $${TEST_TITLES}"; \
		echo "UNIQUE_PROJECTS: $${UNIQUE_PROJECTS}"; \
		if [ -n "$${FAILED_TESTS}" ]; then \
			projects_args=(); \
			IFS=","; \
			projects_array=($${UNIQUE_PROJECTS}); \
			for project in $${projects_array[@]}; do \
				projects_args+=("--project=$${project}"); \
			done; \
			echo "$(run) $(config) ${update_snapshots} $${projects_args[@]} -g $${TEST_TITLES}"; \
			$(run) $(config) ${update_snapshots} $${projects_args[@]} -g $${TEST_TITLES}; \
		else \
			echo "$(run) $(config) ${update_snapshots} ${shard} ${grep} ${projects}"; \
			$(run) $(config) ${update_snapshots} ${shard} ${grep} ${projects}; \
		fi'

If you found this helpful feel free to check out https://playwrightsolutions.com!

playwright-json-summary-reporter-fork