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

peter

v2.4.3

Published

Peter Test Framework

Downloads

887

Readme

Peter Test Framework

Peter is designed to be an extremely lightweight and extensible test framework, with a few test drivers included to accomodate most modes of JavaScript testing.

At it's core, Peter was designed with the following intention in mind:

Testing should be as simple as running the file by itself.

Installation

npm i peter

Usage

To run tests:

# Look in the tests/ directory for test files.
npx peter tests/
# Run single test file that's a `.simple` test.
npx peter tests/test.simple
# Enable verbose output (stdout and stderr from tests will be shown).
npx peter -v tests/

Help text:

$ npx peter --help
peter <testPath>

Peter Test Framework
Copyright (c) 2020-2023 Distributive Corp., All Rights Reserved.

Positionals:
  testPath  The path to a file or directory to run tests from.          [string]

Options:
  --help             Show help                                         [boolean]
  --version          Show version number                               [boolean]
  --concurrency, -j  How many tests should be run in parallel. Providing 0 will
                     use 2x # cores (6 on this system).             [default: 2]
  --envFile, -e      Path to a ".env" test environment file
                                                 [string] [default: ".env.test"]
  --junit, -J        Path to write JUnit report file                    [string]
  --verbose, -v      Enable verbose output (stdout and stderr from tests will be
                     shown).                          [boolean] [default: false]
  --quiet, -q        Never show stderr from tests                      [boolean]
  --debug, -d        Show debugging information (or set DEBUG=peter)
                                                      [boolean] [default: false]
  --timeout, -t      Set a timeout in seconds for tests. 0=forever
                                                        [number] [default: 3600]

Updates

| Version | Date | Description |---------|----------|----------------------- | 2.2.0 | Jun 2021 | Add JUnit XML output | 2.3.0 | Apr 2022 | Add .skip and .failing

Drivers

A peter driver is a module which is responsible for handling files with a specific file extension. The following drivers are included with Peter by default: | Driver Name | File Extension | Description | |-------------|----------------|-------------| | TAP | .tap | This driver will run JavaScript files with the .tap extension, and expect the standard output of the file to be in TAP format. We recommend using zora as a testing library that outputs TAP. | | Simple | .simple | This driver will execute JavaScript files with the .simple extension, and simply assert that no errors were thrown during execution. Top-level await is supported. Tests with lines matching // peter-timeout: NUMBER or /* peter-timeout: NUMBER */ will have the timeout set to NUMBER seconds. | | Bash | .bash | This driver will execute Bash scripts as tests, and assert that the exit code of the script is 0. Tests with lines matching # peter-timeout: NUMBER will have the timeout set to NUMBER seconds. |

Note that files with the .js extension are ignored by Peter so that utility scripts can be written alongside the test scripts.

Testing Peter

To run the example tests (Peter's self tests), run:

./peter tests

Debugging Simple Tests

If a .simple test fails, you can debug it using

./simple <filename>

This file will use niim by default, but --debugger=<debugger> can be used to specify a debugger. A debugger; call is also automatically added to the start of the .simple file being debugged.

About Peter

Peter is a Pragmatic, Extensible Test Environment / Runner. It was built based on the observation that developers tend to write a lot of little tests during the course of development, but these little tests tend not to get captured into unit tests. The idea with Peter, in particular the simple tests, is to make it possible for developers to simply take these tests -- often one or two lines of code -- and move them into their peter directory, where they become simple pass/fail unit tests.

Architecture

./peter is a test runner, which executes tests in random order and in parallel by traversing directories. The test runner discovers the type of test based on the test's file extension. This file extension is then used to select the appropriate test driver, and the test is run. Certain extensions, such as .js, are reserved for library code which could be used by multiple tests. If the test filename begins with the mathematical not symbol, ¬, the sense of the test is inverted (i.e. a pass becomes a fail and vice-versa).

Simple

Simple tests run in NodeJS. If the file throws an uncaught exception or exits with a non-zero exit code, it fails; otherwise it passes. The Simple test driver plumbs in top-level await on Node to make async/await tests easy to run. Individual tests which run directly in NodeJS will run as .simple tests with no changes. Tests written specifically for this test driver can be run individually via /path/to/simple /path/to/test.

Peter

A special shout-out to Peter DeMartini, who let us have the Peter npm name. Peter is awesome - the end!

Team

Peter was written and is maintained by the team at Distributive. We use it internally to test the Distributed Computer.

  • Wes Garland
  • Ryan Rossitter
  • Ryan Saweczko
  • Andrew Fryer
  • James McDonald
  • Parker Rowe
  • James McDonald
  • Eddie Roosenmaallen
  • Bryan Hoang
  • Nazila Akhavan
  • Will Pringle
  • Smeet Chheda