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-custom-json-summary-report

v2.2.0

Published

generate a customizable text summary of your playwright test results

Downloads

2,027

Readme

📜 🎭 Playwright Summary Report JSON 🎭 📜

Small JSON based custom reporter for Playwright. It can be handy to publish test results for things such as an SNS message or minimal Slack update. This Tool allows you to generate smaller reports with basic info about your test run.

Table of Contents

✨ Installation ✨

Run following commands:

npm

npm i playwright-custom-json-summary-report

yarn

yarn add playwright-custom-json-summary-report

Configuration

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

  reporter: [
    ['playwright-custom-json-summary-report', { outputFile: 'custom-summary.json' }]],
    ['html'], // other reporters
    ['dot']
  ],

The default output location will be to your root as summary.json Including the optional outputFile parameter allows you to specify a custom report location.

Default Output 📜

If you do not pass an outputFile option, then the summary will be generated to a summary.json file in the following format:

{
  "Total Tests in Suite": 30,
  "Total Tests Completed": 30,
  "Tests Passed": 27,
  "Tests Failed": 0,
  "Flaky Tests": 0,
  "Test run was failure free": true,
  "Test Skipped": 3,
  "Duration of CPU usage in ms": 75188,
  "Duration of entire test run in ms": 12531,
  "Average Test Duration in ms": 2506.3,
  "Test Suite Duration": "00:13 (mm:ss)",
  "Average Test Duration": "00:03 (mm:ss)",
  "Number of workers used for test run": 6
}

Customizing Outputs 👨‍💻

You may also create a custom report by leveraging the values in the stats object. To add a custom report leveraging your stats, create a function in the format:

import type { Stats } from 'playwright-custom-json-summary-report';

function customReport(stats: Stats) {
  return `Greetings, hello, ${stats.expectedResults} tests passed as expected in ${stats.formattedDurationSuite}`;
}

export default customReport;

and then modify your playwright.config.ts file with the following:

import type { PlaywrightTestConfig } from '@playwright/test';
import { devices } from '@playwright/test';

import customReport from './customReport';
 // Your custom report path and preferred name


const config: PlaywrightTestConfig = {
  ...
  reporter: [
    ['playwright-custom-json-summary-report', { outputFile: 'custom-summary.json', inputTemplate: customReport }]]
  ],

this will generate a custom-summary.json file such as :

hello, 50 tests passed as expected in 03:51 (mm:ss)

Available Stats 🧰

The stats object provides information on your test suite:

| Name | type | Description | |--------------------------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------| | testsInSuite | number | Total number of tests in suite | | totalTestsRun | number | total tests run. Retried tests can make this value larger than testsInSuite | | expectedResults | number | total test finished as expected | | unexpectedResults | number | total tests not finished as expected | | flakyTests | number | total of tests that passed when retried | | testMarkedSkipped | number | total tests marked as test.skip() or test.fixme() | | failureFree | boolean | returns true if suite completes with all test completing as expected after retries | | durationCPU | number | total milliseconds spent run tests. If tests run parallel with multiple workers, this value will be larger than the duration of running the suite | | durationSuite | number | milliseconds to complete all tests in suite | | avgTestDuration | number | average test duration of all tests in milliseconds | | formattedDurationSuite | string | duration to complete all tests in mm:ss format | | formattedAvgTestDuration | string | average test duration of all tests in mm:ss format | | failures | object | an object containing each failure in the format {[test.title: result.status]} Retries with failures will populate this with multiple entries of the same test | | workers | number | total number of workers used to run the suite |

Credit 👏🏻

Special thanks to Stephen Kilbourn.

The original code, which served as the foundation for this work, was sourced from his Git repository. The code has been modified to meed the unique needs and goals for my project.