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

chuckie

v1.1.0

Published

Framework for writing functional tests with mocha and puppeteer

Readme

Chuckie

This is a framework with helper methods intended to ease building functional tests with puppeteer.

handleRejection

Like people, APIs and package sometimes don't handle rejection very well. This can be a bother, especially when writing functional tests where cryptic unhandled Promise rejection can make for frustrating debugging. This class returns a copy of an input object with all it's functions wrapped in try catch block and will execute an input delegate in the catch block.

Example

An usual test with puppeteer could look like this

 it('Should be able to open the loginform', async function() {
        await myPage.goto(config.homeURL);
        await myPage.waitFor('[data-test-id="header-flyout__login-link"]');
        await myPage.click('[data-test-id="header-flyout__login-link"]');
        await myPage.waitFor('[data-test-id="loginform"]');
    });

If you wanted to display proper failure messages it would look something like this

 it('Should be able to open the loginform', async function() {
        await myPage.goto(config.homeURL)
        .catch((err) => assert.fail('', '', 'Error waiting for homepage: ' + err));
        await myPage.waitFor('[data-test-id="header-flyout__login-link"]')
        .catch((err) => assert.fail('', '','Error waiting for selector [data-test-id="header-flyout__login-link"]: ' + err));
        await myPage.click('[data-test-id="header-flyout__login-link"]')
        .catch((err) => assert.fail('', '','Error trying to click on selector [data-test-id="header-flyout__login-link"]: ' + err));
        await myPage.waitFor('[data-test-id="loginform"]')
        .catch((err) => assert.fail('', '','Error waiting for selector [data-test-id="loginform"]: ' + err)));
    });

With handle-rejection it would look like this

 it('Should be able to open the loginform', async function() {
        var delegate = function(error, methodName, args) {
            assert.fail('','', 'Function ' + methodName +
            ' rejected with arguments ' + JSON.stringify(args) +
            '\n' + error);
         };
        myPage = handleRejection(myPage);
        await myPage.goto(config.homeURL);
        await myPage.waitFor('[data-test-id="header-flyout__login-link"]');
        await myPage.click('[data-test-id="header-flyout__login-link"]');
        await myPage.waitFor('[data-test-id="loginform"]');
    });

logPageStatus

Chuckie also provides a method that logs the HTML of a page to a file and takes a screenshot. This process runs async so you should pass it the done method of your mocha tests, so Chuckie can finish writing the file before mocha shuts down.

Full example

const puppeteer = require('puppeteer');
const faker = require('faker');
const config = require('./config');
const assert = require('chai').assert;
const handleRejection = require('./handleRejection');
const logPageStatus = require('./logPageStatus');

before(async function(done){
    faker.locale = "nl";
    browser = await puppeteer.launch(
       config(process.env)
    );
    var delegate = function(error, methodName, args) {
        assert.fail('','', 'Function ' + methodName +
    ' rejected with arguments ' + JSON.stringify(args) +
    '\n' + error);
    };
    myPage = await browser.newPage().then(page => handleRejection(page, delegate));
    done();
});


describe('Account login', function() {
    var firstFailed = false;
    it('Should be able to open the loginform', async function() {
        await myPage.goto(config.homeURL);
        await myPage.waitFor('[data-test-id="header-flyout__login-lin"]');
        await myPage.click('[data-test-id="header-flyout__login-link"]');
        await myPage.waitFor('[data-test-id="loginform"]');
    });

    afterEach(function (done) {
        if (!firstFailed && this.currentTest.state !== 'passed') {
            firstFailed = true;
            logPageStatus(myPage, 'test/functional/logs/account-fail', done);
        }else{
            done();
        }
    });
});

after(function() {
    if (!process.env.DEBUG) {
        browser.close();
    }
});