Giter VIP home page Giter VIP logo

k6-html-reporter's Introduction

k6-html-reporter

A light weight html reporter for k6

Build Status npm npm

Install

NPM:

npm install k6-html-reporter --save-dev

YARN:

yarn add k6-html-reporter --dev

Usage

  1. Install the package
  2. Create a js/ts file and specify the options:
const reporter = require('k6-html-reporter');

const options = {
        jsonFile: <path-to-json-report>,
        output: <path-to-output-directory>,
    };

reporter.generateSummaryReport(options);
    

for typescript

import {generateSummaryReport} from 'k6-html-reporter';

const options = {
        jsonFile: <path-to-json-report>,
        output: <path-to-output-directory>,
    };

generateSummaryReport(options);
  1. Output a JSON summary output with the handleSummary function provided by k6, more info.
export default function () { /** some tests here */}
export function handleSummary(data) {
  console.log('Preparing the end-of-test summary...');
  return {
      <path-to-json-report>: JSON.stringify(data),
  }
}

Note: The --summary-export=path/to/file.json run option is no longer recomanded after k6 v0.30.0.

  1. Run the code in step two as a node.js script after the test execution:
node xxxx.js

Sample report:

Alt text

k6-html-reporter's People

Contributors

szboynono avatar thim81 avatar

Stargazers

Yury avatar Özgür Adem IŞIKLI avatar  avatar Michał Jastrzębowski avatar Serge Smirnov avatar Elio Esteves Duarte avatar  avatar  avatar  avatar Chris Kempster avatar Adithya Jayasankar avatar Chris Kempster avatar Bheem avatar  avatar André Ramos avatar Sabarimuthukumar avatar Luke Howsam avatar  avatar I Dewa Putu Ardi Nusawan avatar Avre Barra avatar Łukasz Rżanek avatar codebymikey avatar  avatar

Watchers

James Cloos avatar  avatar

k6-html-reporter's Issues

Export as plain JS file

Hi @szboynono,

Is there an option that you could generate plain JS file that only exports the writeHtmlReport() but instead of writing it to a file it would just return the output. By doing so, we could load directly in K6, like explained in the handleSummary callback use-case.

Example:

import http from 'k6/http';
import k6example from 'https://raw.githubusercontent.com/loadimpact/k6/master/samples/thresholds_readme_example.js';
export default k6example; // use some predefined example to generate some data
export const options = { vus: 5, iterations: 10 };

// These are still very much WIP and untested, but you can use them as is or write your own!
import { jUnit, textSummary } from 'https://jslib.k6.io/k6-summary/0.0.1/index.js';

export function handleSummary(data) {
    console.log('Preparing the end-of-test summary...');
    return {
         'report.html': k6HtmlReport(data), // Transform to HTML using k6-html-reporter.
    }
}

Trouble following Usage steps

I'm trying to use this with existing tests but having trouble getting it working.

  1. We are using Typescript. I installed the package.
  2. Our tests output a "summary.json" file. Is that what is asked for here? jsonFile: <path-to-json-report>
  3. I have added import { generateSummaryReport } from 'k6-html-reporter';
  4. I added this:
const reportOptions = {
    jsonFile: "summary.json",
    output: ".",
};
generateSummaryReport(reportOptions);
  1. Modified existing handleSummary as follows:
export function handleSummary(data:string):TestSummaryConfiguration {
    return {
        "summary.json": JSON.stringify(data),
    }
//return getSummaryConfiguration(data);
}

I execute a test and they run successfully
Step 4 loses me entirely: "Run the code in step two as a node.js script after the test execution:" I don't know what js file you are referring to.

Apologies if I'm being dense. Appreciate any assistance you can offer.

Strange Character

The converter works really great, but I noticed a strange character (⇀ ) conversion.

See screenshot:

2021-08-26 at 17 49 11

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.