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

results-interpreter

v1.0.0

Published

A Node.js writable stream for interpreting streaming test results

Downloads

1,319

Readme

results-interpreter

A Node.js writable stream for interpreting streaming test results in accordance with a whitelist file.

Build Status

Installation

npm install --save-dev results-interpreter

Usage

var TestInterpreter = require('results-interpreter');

// See the following section, "Input: results stream"
var testResultStream = runMyTests();
// See the following section, "Input: whitelist file"
var interpreter = new TestInterpreter('path/to/a-whitelist-file.txt', {
  // (optional) See the following section, "Output: whitelist file"
  outputFile: 'path/to/another-whitelist-file.txt'
});

testResultStream.pipe(interpreter)
  .on('error', function(error) {
    console.error(error);
    process.exitCode = 1;
  })
  .on('finish', function() {
    // See the following section: "Output: `summary` object"
    console.log(JSON.stringify(this.summary));
    process.exitCode = this.summary.passed ? 0 : 1;
  });

Input: test results stream

Users of this library should provide a Readable object stream which emits data describing test results. Each object must define the following properties:

  • id - type: string; unique identifier describing the test; must be stable across test executions
  • expected - type: string; the outcome that was expected; either "pass" or "fail"
  • actual - type: string; the outcome that was observed; either "pass" or "fail"

Input: whitelist file

The whitelist file is read as a UTF-8-formatted text file. Test IDs must be separated by a newline character. Any text following the "number sign" character (#) will be interpreted as a comment and ignored.

Output: summary object

Once results interpretation is complete (and after a new whitelist file has been created--see below), the stream will define a summary property with an object value. This object contains information about the test results.

  • The following properties contain arrays of testIDs which satisfy expectations:
    • the actual and expected values match, and there is no corresponding entry in the whitelist file
      • summary.allowed.success
      • summary.allowed.failure
    • the actual and expected values do not match, but there is a corresponding entry in the whitelist file
      • summary.allowed.falsePositive
      • summary.allowed.falseNegative
  • The following properties contain arrays of test IDs which violate expectations. If any of these arrays are non-empty, the results are considered "failing", and the summary.passed attribute referenced below will be false
    • the actual and expected values match, but there is a corresponding entry in the whitelist file
      • `summary.disallowed.success
      • `summary.disallowed.failure
    • the actual and expected values do not match, and there is no corresponding entry in the whitelist file
      • summary.disallowed.falsePositive
      • summary.disallowed.falseNegative
    • the test ID was included in the whitelist file, but the provided stream did not emit an object describing a corresponding result
      • summary.unrecognized
  • summary.passed - a boolean attribute describing whether the results completely meet expectations

Output: whitelist file

The stream may optionally output a new version of the whitelist file based on the provided whitelist file. The contents of the output file will be based on the input whitelist, modified to satisfy the behavior of the test run. Specifically:

  • Lines referencing tests which no longer violate expectations will be removed (including trailing comments, if present)
  • The identifiers for tests which violated expectations will be appended
  • Lines referencing tests which had no corresponding object in the provided results stream will be removed (including trailing comments, if present)

All other lines (including comment lines) will be persisted in the output file.

License

Copyright 2017 Mike Pennisi under the GNU General Public License v3.0