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

wpt-runner

v5.0.0

Published

Runs web platform tests in Node.js using jsdom

Downloads

242

Readme

Web Platform Test Runner for Node.js

This package allows you to run tests written in the style of web-platform-tests, but from within Node.js. It does this by running your tests inside a jsdom instance. You can optionally run some setup code beforehand, for example to set up a polyfill that you want to test.

This is useful to a fairly narrow class of consumer: those who both

  1. want to write tests in web-platform-tests format; and,
  2. want to develop and test in a Node.js environment instead of a true browser.

So for example, it might be useful if you're developing a polyfill or reference implementation for a new browser feature, but want to do so in JavaScript, and get the fast no-recompile feedback loop of Node.js.

Command-line Usage

$ node bin/wpt-runner.js
Runs web platform tests in Node.js using jsdom

wpt-runner <tests-path> [--root-url=<url/of/tests/>] [--setup=<setup-module.js>]

Options:
  --root-url, -u  the relative URL path for the tests, e.g. dom/nodes/  [string]
  --setup, -s     the filename of a setup function module               [string]
  --help          Show help                                            [boolean]
  --version       Show version number                                  [boolean]

This will run all .html files found by recursively crawling the specified directory, optionally mounted to the specified root URL and using the specified setup function. The program's exit code will be the number of failing files encountered (0 for success).

Programmatic Usage

The setup is fairly similar. Here is a usage example:

const wptRunner = require("wpt-runner");

wptRunner(testsPath, { rootURL, setup, filter, reporter })
  .then(failures => process.exit(failures))
  .catch(e => {
    console.error(e.stack);
    process.exit(1);
  });

The options are:

  • rootURL: the URL at which to mount the tests (so that they resolve any relative URLs correctly).
  • setup: a setup function to run in the jsdom environment before running the tests.
  • filter: a function that takes the arguments testPath and testURL and returns true or false (or a promise for one of those) to indicate whether the test should run. Defaults to no filtering
  • reporter: an object which can be used to customize the output reports, instead of the default of reporting to the console. (Check out lib/console-reporter.js for an example of the object structure.)

The returned promise fulfills with the number of failing files encountered (0 for success), or rejects if there was some I/O error retrieving the files.