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 🙏

© 2026 – Pkg Stats / Ryan Hefner

cltester

v0.5.1

Published

Automate command-line testing

Readme

cltester

Simple end-to-end command-line testing

  • Give the test a name.
  • Set the command line.
  • Set what you expect to see in standard out and standard error.
  • Run it.

new CLTester('order two toppings', 'orderPizza large [mushrooms,peppers]')
      .standardOutMustMatch('Ordered large pizza with mushrooms and peppers!')
      .run();

This creates a test named order two toppings.
The command line is orderPizza large [mushrooms,peppers].
The test expects standard out to exactly match Ordered large pizza with mushrooms and peppers!
The test is executed.

If the expectation is met, CLTester will write

Pass [order two toppings]

to standard out.

If the expectation is not met, CLTester will write

Failure [order two toppings]
   PROBLEM: stdout does not contain expected value
   EXPECTED: Ordered large pizza with mushrooms and peppers!
   ACTUAL: Ordered large pizza with mushrooms!

to standard out.

If you prefer to see only failures, silence successful tests with the setTerse() function.

new CLTester('order small', 'orderPizza small')
      .standardOutMustMatch('Ordered small pizza with no toppings!')
      .setTerse()
      .run();

If the expectation is met for this test, CLTester will not write anything to standard out.

Expectations

| Expectation | Description | | ----------- | ----------- | | standardOutMustMatch | standard output must match this string exactly | | standardOutMustNotMatch | standard output must not match this string | | standardOutMustContain | standard output must contain this string | | standardOutMustNotContain | standard output must not contain this string | | standardErrMustMatch | standard error must match this string exactly | | standardErrMustNotMatch | standard error must not match this string | | standardErrMustContain | standard error must contain this string | | standardErrMustNotContain | standard error must not contain this string |

CLTester Tests

See CLTesterTest.js for usage examples.

Note that this tests a testing utility, so uses a bit of trickery. We want to verify that failing tests are reported correctly. In this case the failures are expected, so they are considered passing tests. The convert_good_failures.sh script handles this. If you run

node test/CLTesterTest.js

you will see a number of test faiures. These are tests whose names end with "_ShouldFail". convert_good_failures.sh script changes these to say "Pass".

The test in package.json pipes the test output through convert_good_failures.sh (and through sed to remove blank lines). If you run

npm test

you should see all tests pass.

For Windows

convert_good_failures.sh will of course not work in Windows. If you want to test CLTester, you can do either of the following.

  1. Use node to run the tests directly

node test/CLTesterTest.js

  1. If you want to run the tests with the npm test command, change the test script in package.json from

"node test/CLTesterTest.js | ./test/convert_good_failures.sh | sed /^$/d"

        to

"node test/CLTesterTest.js"

In either case, on Windows, you will see the expected failures appear as failing tests. That's okay. They're supposed to fail.

To Do

Regular expressions - Allow callers to pass regular expressions to expectation functions and evaluate them accordingly. It makes sense to use the familiar /regex/ syntax for regexes.