Giter Site home page Giter Site logo

stephenkilbourn / playwright-report-summary Goto Github PK

View Code? Open in Web Editor NEW
14.0 1.0 4.0 116 KB

generate a customizable text summary of your playwright test results

Home Page: https://github.com/stephenkilbourn/playwright-report-summary

License: MIT License

JavaScript 0.66% TypeScript 99.34%
automated-testing playwright playwright-typescript report-generator reporter

playwright-report-summary's Introduction

๐Ÿ“œ ๐ŸŽญ Playwright Report Summary ๐ŸŽญ ๐Ÿ“œ

Coverage Status

Small text 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 install @skilbourn/playwright-report-summary --save-dev

yarn

yarn add @skilbourn/playwright-report-summary --dev

๐Ÿ“ Configuration ๐Ÿ“

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

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

The default output location will be to your root as summary.txt 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.txt 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 '@skilbourn/playwright-report-summary';

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: [
    ['@skilbourn/playwright-report-summary', { outputFile: 'custom-summary.txt', inputTemplate: customReport }]]
  ],

this will generate a custom-summary.txt 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

playwright-report-summary's People

Contributors

stephenkilbourn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.