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

multi-tap

v1.0.1

Published

Spawn and merge tap-producing tests

Downloads

11

Readme

multi-tap

Spawn and merge tap-producing tests. Accepts JavaScript entries (spawns node by default), package.json files or directories containing a package.json (spawns npm run test by default). Can run multiple test scripts per package, with glob pattern support.

npm status node

example

Let's say we have a monorepo with a bunch of packages with self-contained tests, as well as functional tests at the root of the monorepo:

test.js

require('tape')('monorepo', function (t) {
  t.ok(true, 'beep')
  t.end()
})

packages/has-window/index.js

module.exports = function hasWindow () {
  return typeof window !== 'undefined'
}

packages/has-window/test.js

const test = require('tape')
    , hasWindow = require('.')

test('return value', function (t) {
  const expected = !!process.browser
  t.is(hasWindow(), expected, 'value is ' + expected)
  t.end()
})

packages/has-window/package.json

{
  "name": "has-window",
  "scripts": {
    "test:node": "node test.js",
    "test:browser": "browserify test.js | smokestack",
    "test": "multi-tap -r test:*"
  }
}

With multi-tap, we can run all three test suites:

> multi-tap test-*.js packages/*
TAP version 13
# monorepo
ok 1 beep
# has-window › browser › return value            
ok 2 value is true
# has-window › node › return value                    
ok 3 value is false
1..3
# tests 3
# pass  3

# ok

multi-tap [options] [pattern(s)]

Options

 --run            -r  npm script(s) to run ("test")
 --ignore-missing -i  don't fail on missing npm scripts (false)
 --basedir        -b  resolve patterns from this path (cwd)
 --cwd            -c  working directory for js entries (cwd)
 --binary      --bin  command for js entries ("node")
 --stderr         -e  inherit standard error (false)
 --fail-fast      -f  if a test fails, cancel subsequent tests (false)
 --version        -v  print multi-tap version and exit

Spawn npm test for packages/one and packages/two, pipe the merged output to the tap-spec reporter:

multi-tap packages/{one,two} | tap-spec

Spawn beep <file> in working directory /tmp for each file in test:

multi-tap --bin beep --cwd /tmp test/*.js

Spawn two npm scripts in the current directory:

multi-tap -r test-node -r test-chrome

Short options can be joined together. This runs the test suites of modules/middleware-*, fast failing, showing stderr, and ignoring packages without a test script:

multi-tap middleware-* -efib modules | faucet

multitap([pattern(s)], [options])

const multi = require('multi-tap')

multi(['modules/*'])
  .pipe(process.stdout)

options

These options are available for both the CLI and API:

  • basedir: resolve patterns from this path, defaults to process.cwd()
  • stderr: inherit standard error (false)
  • failFast: if a test fails, cancel subsequent tests (false)

Additional options that only apply to packages:

  • run: npm script(s) to run ("test")
  • ignoreMissing: don't fail on missing npm scripts. Adds a passing assertion with a skip directive. Default behavior is to add a failing assertion with a TODO directive.

Additional options that only apply to js entries:

  • cwd: working directory, defaults to process.cwd()
  • binary: command to run, defaults to node

Unix note: if your shell performs glob expansion but you want to resolve glob patterns from basedir, quote or escape the pattern(s) so that multi-tap performs the glob expansion instead:

# a.js, b.js
multi-tap --basedir lib *.js

# lib/a.js, lib/b.js
multi-tap --basedir lib \*.js

install

With npm do:

npm install multi-tap

changelog

1.0.0

  • Run tests in series
  • Rename --runner/-r to --binary/--bin
  • Add --run/-r to specify npm script(s) with glob support
  • Check if npm script(s) are defined before spawning
  • Add --fail-fast/-f option
  • Prefix TAP comments with package name and npm script

license

MIT © ironSource.