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

pull-test

v1.2.3

Published

run assertion tests using pull streams

Downloads

19

Readme

pull-test

run assertion tests using pull streams

npm install --save-dev pull-test

example

// example.js
module.exports = {
  'it succeeds': function (assert) {
    assert(true)
  },
  'it fails!': function (assert) {
    assert(false)
  },
  'it errors!': function (assert, cb) {
    cb(new Error('error'))
  }
}

pull-test example.js

✔ it succeeds
✖ it fails!
{ AssertionError: false == true
   at tests (pull-test/example.js:9:5)
 name: 'AssertionError',
 actual: false,
 expected: true,
 operator: '==',
 message: 'false == true',
 generatedMessage: true }
▲ test runner ended with an error
Error: error
   at tests (pull-test/example.js:12:8)

cli

if test/*.js represents a set of files exporting tests,

runs these tests using built-in assert and default reporter with:

pull-test test/*.js

api

test = require('pull-test')

test(tests)

runs tests using built-in assert and default reporter.

testSource = test.from(tests)

creates a source pull stream of test objects,

from any of the following format of tests:

function testTheThing (assert, cb) {
  assert(true), cb()
}
{
  ['test the thing']: function (assert, cb) {
    assert(true), cb()
  }
}
[{
  name: 'test the thing',
  test: function (assert, cb) {
    assert(true), cb()
  }
}]

through = test.Tester(options)

creates a through pull stream,

which expects to receive test objects with shape:

  • name: name of the test
  • test: function which receives (assert, cb). assert is the same as the node core assert module and automatically collects errors. cb is to be called when the test is done, or the test runner has errored (it will close the stream with the error).

and will return test result objects with shape:

  • name: name of test
  • assertions: array of assertions results from running test. either true if assertion passed or an instance of assert.AssertionError if assertion failed.
  • duration: number of microseconds that test took to run

sink = test.Reporter(options)

creates a sink pull stream,

which receives test result objects and logs to the console.

license

The Apache License

Copyright © 2016 Michael Williams

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.