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

jones-test

v1.4.0

Published

Asynchronous Test Harness

Downloads

13

Readme

Jones Test

Jones-test is an asynchronous test harness for node.js. For independent tests that require file or network I/O, it can run many tests at once. It originated from the "Database Jones" project at github.com/mysql/mysql-js, where it is used to run several hundred tests in just a few seconds.

Using Jones Test

Tests are organized by suites. Normally, each suite is contained in a directory under the main test directory. Suites can contain the following four sorts of functional tests:

  • SmokeTest: set up and verify the test environment (create tables, populate data in tables, open a connection to the database, etc.). If a SmokeTest fails, then the remaining tests in a suite will not be run.
  • ConcurrentTest: tests to be run concurrently, using the test setup (test schema and test data) and having no side effects (do not insert or delete any rows in the database)
  • SerialTest: tests to be run serially, using the test setup. These tests can have side effects, except for changing schema or databases that other tests depend on. Tests that change schema should generally be in their own test suite.
  • ClearSmokeTest: tear down the test environment (drop tables, databases)

A functional test is created by using one of the four constructors in the list above, and defining a run() method, in a file whose name ends with "Test.js".

In addition to the functional tests, suites may contain two sorts of static code analysis tests.

  • LintTest: tests that run a lint utility, such as jslint, on a project's source files.
  • DocsTest: tests that verify the methods stated in a documentation file against the methods provided by an implementation object. The documentation may be a JavaScript file, or it may be the JavaScript content within a Markdown file. If a documented function is not provided by the implementation, the test fails.

The run() function

Functional tests are either synchronous or asynchronous depending on the behavior of the run() function.

Synchronous tests must return true from the run() function. They are considered to pass if the errorMessages string is empty, and considered to fail if the errorMessages string is not empty. An error may be appended to the errorMessages string by calling the function appendErrorMessage(). A synchronous test that throws an exception is also considered to fail.

Asynchronous tests need not return anything from the run() function and must not return true. They must call the pass or fail function when they complete. This can be done explicitly or by using one of the functions declared in Test:

test.fail('failure message'); // fails with the failure message as the reason
test.failOnError(); // fails test if the errorMessages string is not empty

Error messages can be appended based on conditions, by using helper functions, e.g.

test.errorIfNotEqual(message, object1, object2)

Exporting tests from test files

Test programs that implement one test can export that test:

module.exports = test1;

Test programs that implement multiple tests should export the array of tests:

module.exports.tests = [test1, test2];