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

tape-worm

v0.0.3

Published

Put tape's TAP output into the DOM, and add html injection method.

Downloads

44

Readme

tapeworm

Tapeworm allows you to the DOM as a reporter when testing in the browser using tape.

Tapeworm adds three features to tape.

  1. Spits the test results into the DOM.
  2. Colors the background and favicon; green for passing, red for failing, yellow for pending.
  3. Adds an t.html method, where you can inject any arbitrary html into the DOM.

Screenshots

Passing

passing-test-screenshot

Failing

passing-test-screenshot

t.html

This is the main reason that tapeworm exists. By allowing you to add your own html you gain a really powerful test reporter.

Take these two images for example:

two-worms one-worm

We can write a simple test using Resemble.js to diff the images.

test('the worm images should look the same', function (t) {

  t.plan(1);

  resemble('two-worms.jpg').compareTo('one-worm.jpg')
    .onComplete(function (imgDiffResult) {

      var pass = imgDiffResult.rawMisMatchPercentage === 0;

      if (!pass) {
        var base64DiffData = imgDiffResult.getImageDataUrl();
        t.html('<img src="' + base64DiffData + '">');
      }

      t.equal(pass, true);
    });
});

And now we have image diffs in our output, whoop!

diff-worms

Installation and Usage

npm install tape-worm

Tapeworm is designed to run with tape and all it's variants (blue-tape, redtape, etc). All you need to do is import it into your test file and then infect tape.

// test.js
var test = require('tape');
var tapeworm = require('tape-worm');

tapeworm.infect(test);

Use browserify to bundle up the code for browser

browserify test.js > test-bundle.js

Create a simple html wrapper (you need the head section for the favicon injection)

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>tests</title>
  </head>
  <body>
    <script src="test-bundle.js"></script>
  </body>
</html>

Now load this into the browser and you're done.

If you want it to reload on save you might end up with something like this:

watchify test.js -o test-bundle.js -vd & live-server --watch=test-bundle.js

Warning

Calling tapeworm.infect(test) is monkey patching and you should be aware of the potential pitfalls.