API: reporting on a test

👵 fully programmable stress testing framework


API: reporting on a test

Table of Contents

grandma.report({Object} options, {Function} callback) → void

The run command takes an options object and a callback.

options:

The following options are available for reporting on a test log:

  • type {string} - text, json, box, plot, or html. Default is json.
  • input {stream} - readable stream of report data generated by grandma.run.
  • output {stream} - writable stream to output the report to. This value is optional for the json type is specified.
  • metadata {string} - used with type: 'html', provides metadata that will be included in the report as plain text.
  • box {object} - options of the box plot type.
    • width {number} - the maximum width, in characters, of the box plot. Default is 75.

callback:

Json example:

var fs = require('fs');
var input = fs.createReadStream('path/to/a/grandma.log');

var grandma = require('grandma');

grandma.report({
    input: input,
    type: 'json'
}, function(err, jsonObj) {
    if (err) {
        console.error('something went horribly wrong', err);
    } else {
        console.log(jsonObj);
    }
});

Text example printing to standard out:

var fs = require('fs');
var input = fs.createReadStream('path/to/a/grandma.log');
var output = process.stdout; // print to the console

var grandma = require('grandma');

grandma.report({
    input: input,
    output: output,
    type: 'text'
}, function(err) {
    if (err) {
        console.error('something went horribly wrong', err);
    } else {
        console.log('the report was written to the output stream');
    }
});

Plot example writing to a file:

var fs = require('fs');
var input = fs.createReadStream('path/to/a/grandma.log');
var output = fs.createWriteStream('path/to/a/report.html');

var grandma = require('grandma');

grandma.report({
    input: input,
    output: output,
    type: 'plot'
}, function(err) {
    // ...
});

HTML example, including all environment variables as metadata:

var fs = require('fs');
var input = fs.createReadStream('path/to/a/grandma.log');
var output = fs.createWriteStream('path/to/a/report.html');

var grandma = require('grandma');

grandma.report({
    input: input,
    output: output,
    type: 'html',
    metadata: JSON.stringify(process.env, null, 2)
}, function(err) {
    // ...
});