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 🙏

© 2025 – Pkg Stats / Ryan Hefner

rtest

v0.0.15

Published

A module for automating web testing

Readme

RTest

Web site scanning and testing made easy

Project Page: https://github.com/rorymurphy/rtest

RTest makes ensuring consistency across every page on all your web sites a snap. After defining a set of test, all you have to specify is any entrypoint URL and a few options, and RTest will do the rest. It will crawl your web site, executing your tests against each response. Your tests can access all the standard attributes of the response - url, headers, body, as well as a jQuery-like (cheerio) object for the response body that can be used to test the structure of the document.

Syntax

rtest <options> <test file 1> ... <test file n>

Options

| Flag | Description | | ---- | ----------- | | --url -u | Specifies a Url that serves as an entrypoint for the crawler - can be used multiple times. | | --includeDomain -i | Adds a domain to the list of domains to be included in the crawl. If used, white-list scanning is enabled and only those domains specifically included will be scanned. This option may be repeated to include multiple domains. However this option is mutually exclusive with --excludeDomain. | | --excludeDomain -x | Adds a domain to the list of domains not included in the crawl. If used, black-list scanning is enabled and all domains will be included unless specifically excluded. This option may be repeated to exclude multiple domains. It is mutually exclusive with --includeDomain. | | --maxPages | The maximum number of pages that should be crawled. | | --maxConnections | The maximum number of simultaneous connections that can be open at any given time. It is important not to set this too high unless you have a web farm capable of handling it. The crawler is capable of opening thousands of simultaneous connections due to node's asynchronous IO, which is more than many traditional web servers can handle | | --fetchTimeout | The amount of time to wait to retrieve a page before giving up, specified in milliseconds | | --noCss | Forces the crawler to ignore CSS references | | --noImages | Forces the crawler to ignore image references | | --noScripts | Forces the crawler to ignore scripts |

Example Test File

var rtest = require('./rtest');

//The module exports must be an array of tests
module.exports = [
    rtest.test("Not an error code", function(assert, response){
        //Assert that the response code is not an error code (a 4XX or 5XX) status
        assert.isTrue(response.statusCode < 400, 'URL returned a status code ' + response.statusCode);
    }),

    rtest.test("Optimize with 1 CSS file", function(assert, response){
        //Assert that there is only one link element of type text/css
        assert.areEqual(1, response.$('link[type="text/css"]').length, "More than one stylesheet found", "WARN"); 
    })
];

The assert object

The assert option provides methods for testing various conditions and outputting the result to the console, along with some basic information about the request being tested. The errorLvl argument should be one of "FATAL", "ERROR", "WARN", "INFO" or "DEBUG". The assert object has the following methods:

| Signature | Description | | ------ | ----------- | | isTrue(truthTest, msg, errorLvl) | accepts a single value and evaluates it as truthy or not (using ==), logs the specified msg if it is not | | areEqual(expected, actual, msg, errorLvl) | accepts two values and tests their equality using === checking, logs the specified msg if not | | areNotEqual(notExpected, actual, msg, errorLvl) | reverse of areEqual | | success(msg) | logs a success message | | failure(msg, errorLvl) | unconditionally logs an error message with the specified errorLvl |

The response object

| Property | Description | | -------- | ----------- | | url | the requested url | | body | the body of the HTTP request in string form - may be HTML or binary | | refs | other URLs that are referenced by this document - only parsed for HTML or CSS documents | | referrers | URLs that have been crawled and reference this document. Only contains pages that have already been crawled and parsed, so list is likely incomplete but can be very helpful in diagnosing where resources returning a 404 are being referenced. | | statusCode | the HTTP status code returned by the server | | headers | a javascript object with the header names as keys and values. The content-type is often a header of particular interest in order to write tests that only pertain to a particular resource class | | $ | the jQuery-like cheerio object for the document root that can be used to run queries against the page structure - only populated for HTML responses |