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

parallel-test

v3.0.4

Published

This test runner runs all asynchronous tests concurrently, which can speed up tests if a test suite includes lots of tests that perform asynchronous operations.

Downloads

89

Readme

This test runner runs all asynchronous tests concurrently, which can speed up tests if a test suite includes lots of tests that perform asynchronous operations.

I made this because I didn't find another runner that runs all tests at once.

Usage

As of v3.0.0, ESM is required

An assertion library isn't included, so use whichever you'd like. I like to use node's assert library. If the errors thrown include expected and actual properties (like in the node assert library), a diff will be displayed.

A test ends when its code finishes running, or the promise it returns has settled.

TAP messages are printed, so feel free to use whichever TAP formatter you like. Tape has a nice list.

Tests must be registered synchronously after the first test is registered.

Events are emitted as tests run. The emitter is exported as testEvents from the main file. It's typed, so inspect its types to see which events are available.

For usage examples, see the src/test/ directory.

How to make tests safe to run with other tests

Many tests are written assuming that they'll run on their own, and won't interact with other tests, and as a result, aren't safe to run at the same time as each other. For example, a test that reads from a database might set up the test by writing a record, and then read the written record by assuming that its auto-generated sequential ID is 1. If many tests are running concurrently, such assumptions aren't safe, and will result in test failures.

Generally, to write tests that are safe to run with other tests:

  • Never use hard-coded identifiers or data that cannot be unique.
    • For example, rather than assuming that the record you wrote has ID 1, ask the database to return the auto-generated ID when the record is created, and use it to retrieve the record later.
    • For example, if there's a unique constraint on email addresses, use randomly-generated addresses.
  • If rate limits are a concern, make sure the operations your tests perform are rate limited, rather than relying on tests being rate limited.

Future improvements

  • a "watch" mode, in which:
    • The results of globbing are cached
    • The modules loaded are cached, and only added, removed, or updated as necessary
      • it might also be useful to have an option to re-run only the test files that were changed, for times when tests are being developed
  • helpers for beforeAll, afterAll, beforeEach, afterEach. They might be implemented as functions that accept test and a callback, and returns a modified version of test that will run the hooks. There could be a separate function for each one, or a single addHooks function that accepts multiple hooks