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

@socketsupply/tapzero

v0.8.0

Published

Smallest test library

Downloads

35

Readme

@socketsupply/tapzero

Zero dependency test framework

Source code

The implementation is <250 loc, (<500 with comments) ( https://github.com/Raynos/tapzero/blob/master/index.js ) and very readable.

Migrating from tape

const tape = require('tape')
// Tapzero exports an object with a test function property.
const tapzero = require('@socketsupply/tapzero').test
tape('my test', (t) => {
  t.equal(2, 2, 'ok')
  t.end()
})
// Auto ending behavior on function completion
tapzero('my test', (t) => {
  t.equal(2, 2, 'ok')
  // t.end() does not exist.
})

End "automatically" if you do not call t.plan

// tapzero "auto" ends async tests when the async function completes
tapzero('my cb test', async (t) => {
  await new Promise((resolve) => {
    t.equal(2, 2, 'ok')
    setTimeout(() => {
      // instead of calling t.end(), resolve a promise
      resolve()
    }, 10)
  })
})

Plan the number of assertions

tapzero('planning example', t => {
  // this test will fail if we execute more or fewer
  //   than planned assertions
  t.plan(2)
  t.ok('hello')
  t.equal(2, 2, 'two is two')
})
tape('my test', (t) => {
  t.equals(2, 2)
  t.is(2, 2)
  t.isEqual(2, 2)
})
tapzero('my test', (t) => {
  // tapzero does not implement any aliases, very small surface area.
  t.equal(2, 2)
  t.equal(2, 2)
  t.equal(2, 2)
})

Motivation

Small library, zero dependencies

$ package-size ./build/src/index.js zora baretest,assert qunit tape jasmine mocha

  package                      size       minified   gzipped
  ./build/src/index.js         8.97 KB    3.92 KB    1.53 KB
  [email protected]                   32.44 KB   11.65 KB   4.08 KB
  [email protected],[email protected]  51.61 KB   16.48 KB   5.82 KB
  [email protected]                  195.83 KB  62.04 KB   20.38 KB
  [email protected]                  304.71 KB  101.46 KB  28.8 KB
  [email protected]                413.61 KB  145.2 KB   41.07 KB
  [email protected]                  811.55 KB  273.07 KB  91.61 KB

Small library, small install size.

| | @socketsupply/tapzero | baretest | zora | pta | tape | |--------|:---------:|:----------:|:------:|:-----:|:------:| |pkg size| tapzero | baretest | zora | pta | tape | |Min.js size| @socketsupply/tapzero | baretest | zora | pta | tape | |dep count| @socketsupply/tapzero | baretest | zora | pta | tape |

| | Mocha | Ava | Jest | tap | |:------:|:-------:|:-----:|:------:|:-----:| |pkg size| mocha | ava | jest | tap | |Min.js size| mocha | ava | jest | tap | |dep count| mocha | ava | jest | tap |

Docs

const test = require('@socketsupply/tapzero').test

test(name, [fn])

Run a single named test case. The fn will be called with the t test object.

Tests run one at a time and complete when the fn completes, the fn can be async.

test.only(name, fn)

Like test(name, fn) except if you use .only this is the only test case that will run for the entire process, all other test cases using tape will be ignored.

test.skip(name, [fn])

Creates a test case that will be skipped

Harness docs

const testHarness = require('@socketsupply/tapzero/harness')

See HARNESS.md