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

masking-tape

v0.0.0

Published

a tape harness with life-cycle hooks.

Downloads

6

Readme

Masking-Tape

A tape test harness with "beforeEach", "afterEach", and "afterAll" lifecycle hooks. Also lets you add an identifying comment to the beginning of each test file's run.

Example:

var mask = require('masking-tape')

// a pretend module that overrides http requests, like sinon's fakeServer,
// perhaps
var mockServer = require('mock-server') 

var server = new mockServer
var test = mask('my bestest test', afterAll, beforeEach, afterEach)

function beforeEach() {
  // maybe we've got a dom available.
  document.body.innerHTML = '<div>test html</div>'
}

function afterEach() {
  server.removeAllEndpoints()
}


function afterAll() {
  mockServer.teardownAll()
}

test('my coolestest test', function(t) {
  /* 
   * This is just a normal tape test.
  */
  t.end()
})

API:

var test = mask(name, afterAll, beforeEach, afterEach)

Arguments

  • name: a string to be printed as a comment before the test runs. Can have multiple lines: Each line will have # prepended to it.

  • afterAll: A function to be run after each test completes. This is necessary because by default tape runs all tests in the same environment, so leaving it out can pollute your test run.

  • beforeEach: A function to be run before each test begins. There is no functionality to schedule the next test after an asynchronous process specified in before completes. The next test will be queued as soon as this function returns.

  • afterEach: A function to be run after each tests completes. masking-tape does not support asynchronous function calls here, meaning that the next test will be queued as soon as this function returns.

Errors occurring in these functions are unhandled. Tracebacks should be easy to follow because of the complete lack of asynchronous support.

Return Value

A tape test harness.

Note:

The function returned by require('masking-tape') has an attribute attached to it called .stream. require('masking-tape').stream is a function that returns a stream. tape's stream of text data is piped into the returned stream in order to report test results. The "class" method is available to support tests, but you could also use it to report test results across a network, or in a browser. The default stream lives in lib/reporter.js

Why should I use this module as opposed to <insert module here>

This module implements its functionality without overriding any tape methods, or adding unnecessary clutter to tape's output. It simply makes a test harness, and creates an object stream which informs the client of the test's life-cycle.

The only caveat is we had to write a custom reporter stream for writing to stdout, since tape does not expose the reporter it uses internally.

Contributing:

Please see the contributing guidelines.

License:

APACHE V2