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

testeachversion

v9.0.0

Published

Run a test against each version of a package

Downloads

102

Readme

testeachversion

testeachversion runs your test suite against each versions of the packages you depend on. You create a config file specifying the versions of the modules/packages you want to test, the version range(s) for each, and the task you want to run. You should use the VersionSpec class to define your config file. N.B. VersionSpec does no error checking at this time so you probably want to keep the config file straightforward and simple.

const VersionSpec = require('testeachversion').VersionSpec

const packages = module.exports = []

packages.push(new VersionSpec('ap', {task: 'node index.js'}))

Usage

Basic usage is as simple as running testeachversion from the command line after creating a config file containing the VersionSpecs. testeachversion is located in the ./node_modules/.bin/ directory and is linked to ./node_modules/testeachversion/lib/bin.js. It will look for the config file using the path ./test/versions.js.

There are some useful options, including:

  • -c, --config - Look for version spec file in different location
  • -p, --package - Only run version tests for the specified package
  • -V, --verbose - Include additional output from test runs
  • -s, --suppress - Set -s false to output errors to terminal
  • -v, --version - Show the version and exit

There are options to change the output filenames but the humanize logs program will not find the summary logs then so use at your own risk.

Interpreting the results

Two logs are generated - a summary log and a details log. The details log contains the output from each test run and can be used to better understand how and why specific tests failed. The summary log is in JSON format and captures the tests that were skipped, passed, and failed. It can be interpreted using humanize-log.js (which is linked as node_modules/.bin/humanize).

humanize path [...path] for each file or directory specified by path will select the summary json files and output each package's tests that passed.

humanize path [...path] -a will output each package's skips, passes, and fails.

humanize path [...path] -m or --merge-duplicates will process multiple logs from each os-node-version combination replacing previous results with newer results. this is most useful when specific tests fail and a new test run is made that covers only the failed tests. it is similar to Object.assign(test1, test2) in that test2 results replace test1's previous results. for example, if all the hapi tests failed in test1 you can fix the problem then run testeachversion -p hapi to test only hapi. i always direct log outputs to a log/ so, when testeachversion has completed you can run humanize -m logs/ and it will merge test2 results on top of test1 results, filling in the failed hapi results with new hapi (hopefully successful) results.

Versions File

A typical versions spec file looks something like this:

VersionSpec = require('testeachversion').VersionSpec

module.exports = [
  VersionSpec('express', {ranges: '^4.0.0', task: 'gulp test:express'}),
  VersionSpec('redis', {ranges: '>= 0.8.0', task: 'gulp test:redis'}),
  VersionSpec('vision', {
    task: 'gulp test:vision',
    ranges: [
      {range: '>= 4.0.0 < 5.0.0', dependencies: ['hapi@16']},
      {range: '>= 5.0.0', dependencies: ['hapi@17']}
    ]
  })
]

Ranges are tested using semver.

Defaults:

task: 'false' range: '*' timeout: 60000 (not used currently)

It is possible to specify dependencies that will be used for the matching range. testeachversion will install the dependencies for the range but will not iterate through all matching versions of the dependencies, just the latest for each dependency. E.g., for the vision test the latest version of hapi v16 will be used for each v4 version of vision.

The example/ directory contains an example version file.

History

Version 9.0.0

  • take version-string from command-line. remove hardcoded items inserted into the version string.

Version 8.7

  • primary change is adding versions of tested appoptics components
  • if developing there is a breaking change - mocha and eslint are global installs and were removed from dependencies.

Version 8 is a major rearchitecture for better internal organization.

  • allows testing of node builtin modules, e.g., fs which are have only one version and are already installed.
  • enables function tests again
  • provides a VersionSpec class for use in config files
  • adds testing
  • fixes various bugs

Breaking changes:

  • version file format - requires using VersionSpec class to construct entries
  • reporter interface is completely new (and not well defined)
  • function names and classes are new (only an issue if using the undocumented API - most common use is via lib/bin.js)

Version 7 of testeachversion removes babel and as such requires node version 6+.

This is based on Stephen Belanger's alltheversions.