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

regtester

v0.0.1

Published

A library for doing simple output-based regression tests.

Downloads

2

Readme

regtester

A library for doing simple input/output based regression tests.

The library exports a single class, TestDataFiles, which handles creation of a temporary output directory, comparison of the observed output to the expected output, and automatically printing the diff if the files don't match.

To use:

Install:

 npm install regtester

First, put your input files (if any) in a test-data directory, within the directory that contains your test, e.g.:

 something/something/lib/test
 \_ regtest.coffee
 \_ test-data
   \_ myinputfile

Next, write your test (assumes nodeunit, see below for other test frameworks):

var TestDataFiles = require('regtester').TestDataFiles;
exports.setUp = function(cb) {
  this.testData = new TestDataFiles(__filename);
  cb();
}

// import the function you want to test.
var processFile = require('./the-module-under-test').processFile;

exports.testRegtest = function(test) {
  this.testData.testFile(test, 'myinputfile', function(testHandle) {
    var results = processFile(testHandle.inputPath);
    testHandle.writeObservedOutput(results);
  });
}

Now, generate your expected output:

 $ UPDATE_REGTEST_DATA=1 nodeunit regtest.coffee

The expected output is stored in the test-data directory:

 something/something/lib/test
 \_ regtest.coffee
 \_ test-data
   \_ myinputfile
   \_ myinputfile.expected

Run the test again, it should pass:

$ nodeunit regtest.coffee

If you like, change myinputfile.expected, and verify that the test fails. Add all the new files to git, and you're done!

nodeunit

regtester assumes that you're using nodeunit. If you want to use another framework, you'll need to pass in an object providing the functions normally provided by nodeunit's test handle.

For example:

var testStub = {
  expect: function(n) { /* expect n calls to `ok` before `done` is called */ }
  fail: function(msg) { /* print msg, cause test to fail */ },
  done: function() { /* signals that the test is over (test may be async) */ }
  ok: function(msg) { /* asserts that a particular point in the test was reached */ }
};

testData.testFile(testStub, 'myinputfile', function(testHandle) { ... });