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

run-tests-parallel

v1.0.0

Published

Run test scripts in parallel

Downloads

10

Readme

run-tests-parallel

Install

To add to some other module: npm install --save run-tests-parallel

To run tests in a homemade test harness: npm install --save-dev run-tests-parallel

Usage

While using the node-tap module.

run.js

let rtp = require('run-tests-parallel');
//or es2015 import
//import rtp from 'run-tests-parallel';

rtp(['script1.js', 'script2.js'], {
    tap: true
});

script1.js

let tap = require('tap');

tap.test('Is it ok? 1', t=>{
    t.ok(true);
});

script2.js

let tap = require('tap');

tap.test('Is it ok? 2', t=>{
    t.ok(false);
});

The output of running run.js above should look something like this:

TAP version 13
...truncated for verbosity
# failed 1 test
# time=30.827ms
        function: tap.test.t
      stack: |
        Test.tap.test.t (script2.js:4:7)
        Object.<anonymous> (script2.js:3:5)
      source: |
        t.ok(false);
      ...

    not ok 2 - test unfinished
      ---
      stack: |
        Object.<anonymous> (script2.js:3:5)
      test: bla 2
      at:
        line: 3
        column: 5
        file: script2.js
        function: Object.<anonymous>
      source: |
        tap.test('bla 2', t=>{
      ...

    1..2
    # failed 2 of 2 tests
not ok 2 - bla 2 # time=38.7ms

# failed 1 test
# time=47.011ms

1..2

The API

rtp([scripts,...], options = {})

Run a bunch of test scripts. rtp() returns an object with two streams that looks like this:

{
    //The stream that gets all the child output
    stdout,
    //The stream that gets all the child error output
    stderr,
    //print() is a convenience function for
    //setting the pipe to standard output
    print(){
        this.stdout.pipe(process.stdout);
        this.stderr.pipe(process.stderr);
    }
}

run-tests-parallel with all of it's options, and default values.

rtp(['script1.js', 'script2.js'], {
    argv: [],
    commandOpts: {
        stdio: [null, null, null]
    },
    tap: false,
    failFast: true,
    onError: null
});

options.argv

An array of cli arguments for all the scripts. The default of options.argv is an empty array.

options.commandOpts

An object that is used as options to the child_process spawn function that spawns all the scripts.

In run-tests-parallel stdio is automatically streamed to the main process io (terminal output). See options.stdio next:

options.stdio

The default of options.stdio is true. Set options.stdio to false to prevent the automatic stream to process.stdout, and process.stderr.

options.tap

Tell run-tests-parallel that it should expect TAP output from all the scripts. The default of options.tap is false.

options.failFast

Tell run-tests-parallel whether, or not it should make the main process fail when a child process errors out. When failFast is set to false the main parent process will keep running even if a child errors out.

options.onError

options.onError will be called when a child process errors out.

If options.failFast is set to true options.onError will be called before the main process exits.

About

run-tests-parallel runs a series of scripts in parallel, and merges the streams of those scripts into a single stream for terminal output.