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

ppunit

v1.0.0

Published

Test framework that supports parallelization and promises

Downloads

22

Readme

Build Status

PPUnit is a test framework that supports parallelization and promises, inspired by Mocha.

Currently only supporting a BDD interface but PPUnit can be extended to include more.

Parallelization

By default all tests are run in series and all suites are run in parallel. Test and suite parallelism can be changed on a case by case basis. You can also specifiy a test or suites level of exclusivity, limiting what the test or suite can run with.

  • Non exclusive - Execution is not restricted at all
  • Locally exclusive - These items may not execute alongside any of its siblings.
  • Globally exclusive - These items are the only things allowed to run during their execution.

There is a single rule that can not be changed:

Children suites can not run until their parents tests have completed

Basic Usage

A simple non asynchronous, non paralellized test case

describe('Suite', function () {
    it('1 should equal 1', function () {
        assert(1 === 1, '1 did not equal 1?!')
    })
})

Promises

TODO: Fill in this section Return a promise, it works as you would expect

Async tests

If the test takes an argument it will be considered async and will only be completed once that argument is executed

it('Should do things', function (done) {
    setTimeout(done, 1000)
})

Marking a test as failed

You can throw, return an error, return a promise and fail it, or call done with a value

it('test1', function () {
    throw new Error('Failed')
})

it('test2', function () {
    return new Error('Failed')
})

it('test3', function () {
    var promise = new Promise()

    setTimeout(function () {
        promise.fail(new Error('Because'))
    }, 1000)

    return promise
})

it('test4', function (done) {
    done(new Error('Failed'))
})

it('test5', function (done) {
    done('ermmm')
})

Setting exclusivity

Exclusivity is what controls an items paralellism

On a test (before/each, after/each, and test)

it('Should do something').nonExclusive()
it('Should do something').locallyExclusive()
it('Should do something').globallyExclusive()

On a suite

describe('suite', function () {...} ).nonExclusive()
describe('suite', function () {...} ).locallyExclusive()
describe('suite', function () {...} ).globallyExclusive()

Suites can also set the default exclusivity of all tests within its ancestry (includes child suites)

describe('suite', function () {
    //All three tests would execute in parallel
    it('test1', function () {...})
    it('test2', function () {...})
    it('test3', function () {...})
}).nonExclusiveTests()

describe('suite', function () {
    //All three tests would execute in series and other suites tests may be running as well, this is the default
    it('test1', function () {...})
    it('test2', function () {...})
    it('test3', function () {...})
}).locallyExclusiveTests()

describe('suite', function () {
    //All three tests would execute in series and no other tests would be running, this should be avoided
    it('test1', function () {...})
    it('test2', function () {...})
    it('test3', function () {...})
}).globallyExclusiveTests()

Skip and Only

A test or suite can be marked as skip, which causes everything within that items ancestry to be skipped, unless it is marked as only

describe.skip('suite', function () {
    //This test would be skipped
    it('test1', function () {...})

    //This test would run
    it.only('test2', function () {...})
})

Multiple items can be marked as only, and only those items would be run

describe('suite', function () {
    //test1 and test2 will run, test3 will be skipped
    it.only('test1', function () {...})
    it.only('test2', function () {...})
    it('test3', function () {...})
})

TODO: Explain before/each and after/each only handling

TODO: Explain suite methods

TODO: Explain test methods

TODO: Explain hooks in general

TODO: Explain cli runner

TODO: Explain graphviz stuff