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

@openride/sticky-test

v0.2.2

Published

Tape-inspired test framework

Downloads

9

Readme

Sticky Circle CI

Promise-first testing with no surprises.

If your test runs synchronously, just write it:

const sticky = require('sticky');
const test = sticky();
test(1, 'Department of redundancies department', assert => {
  assert.equal('tautology', 'tautology', 'Pass because it passes');
});

If it's async, just return a promise:

const sticky = require('sticky');
const test = sticky({timeout: 1000});

test(1, 'Off to the races', assert => new Promise(resolve =>
  setTimeout(() => {
    assert(true, 'One day sticky will output in tap format');
    resolve();
  }, 900)));

test(0, 'This test takes FOR EVVVVVVER', () => new Promise(resolve =>
  null));  // `resolve` never gets called so this test times out

outputs:

→ Off to the races (1)
→ This test takes FOR EVVVVVVER (0)
1 tests failed :(
× This test takes FOR EVVVVVVER
  Test rejected with TestTimeout (Test timed out)
  TestTimeout
    at CustomError.Error (native)
    at new CustomError (/home/phil/code/sticky/errors.js:15:27)
    at null._onTimeout (/home/phil/code/sticky/run-one.js:45:25)
    at Timer.listOnTimeout (timers.js:89:15)
FAILED in 1.919s :(

API

sticky(options: object): func

Returns a test function that you can use to register tests to run.

options.timeout: number: How long to wait for an async test before failing it. Defaults to 100ms.

options.registerTimeout: number: How long to keep polling for new tests to be registered since the last test ran. You can call test asynchronously with sticky, no need to register them all in the first tick. However, if you need to start up a slow resource, you may need to increase this timeout. Defaults to 5ms.

test(plan: number, message: string, testFn: func)

Returned from sticky() (see above).

plan: The number of asserts your tests will call.

msg: A description of this test

testFn: a callback to run your actual tests. testFn is called with a single argument, assert. If you return a promise, sticky will wait for it to resolve or reject before moving on to the next test.

assert

Provided as the only parameter to testFn callbacks (see above).

A proxied version of nodejs's builtin assert. The API is the same, except for assert.fail, which only takes a single argument (the message to fail with).

Dev notes

Run sticky's own unit tests with npm test.