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

@oat-sa/tao-qunit-testrunner

v2.0.0

Published

TAO Frontend Unit & Integration Test Runner based on QUnit and Puppeteer

Downloads

172

Readme

tao-qunit-testrunner-fe

TAO Frontend Unit & Integration Test Runner based on QUnit and Puppeteer

How to use

Run all tests:

npx qunit-testrunner

Run specific test:

npx qunit-testrunner <testname>

Enable coverage:

npx qunit-testrunner --cov

Display coverage report

Requirement: npm install nyc

npx nyc report

Generate html coverage report

Requirement: npm install nyc

npx nyc report --reporter=lcov

Environment variables

| Option name | Description | Type | Default | | ---------------- | ------------------------------------- | --------- | ------- | | PARALLEL_TESTS | Define the amount of parallel tests | number | 5 | | REDIRECT_CONSOLE | Redirects browser console to terminal | boolean | false |

Command line arguments

| Option name | Description | Type | Default | | -------------------------- | ----------------------------------------------------- | --------- | ------------------------------- | | --config, -c | Define config file | string | .qunit-testrunner.config.json | | --test-dir, -d | Test directory name in root | string | test | | --root, -r | Root directory name | string | process.cwd() | | --spec | Test files pattern | glob | **/test.html | | --mock-api | Enables API Mock middleware | boolean | false | | --without-server | Start testrunner without server | boolean | false | | --reporter | Test result reporter (json, basic, stats | | | | | or custom path) | string | basic | | --verbose, -v, -vv ... | Verbose level | count | 0 | | --help -h | Display help | boolean | false | | | | | | | Webserver options | | | | | --keepalive | Do not run tests just start webserver | boolean | false | | --host | Webserver host | string | 127.0.0.1 | | --port, -p | Webserver port | number | random free port | | | | | | | Coverage options | | | | | --coverage, --cov | Enable coverage measurement | boolean | false | | --coverage-instrument-spec | Coverage instrument pattern from root | glob | src/**/*.js | | --coverage-output-dir | Coverage output directory in root | string | .nyc_output | | --clear-coverage-dir | Clear the coverage output directory before running | | | | | test, when coverage option is enabled | bool | true |

Config file

In the config file, all command line argument can be defined. If an argument is defined in config and in command line as well, the command line value overrides config value.

.qunit-testrunner.config.json:

{
  "verbose": 1,
  "testDir": "exampleTest",
  "coverage": true,
  "coverage-instrument-spec": "exampleSrc/**/*.js",
  "port": 8082
}

Recommended package.json scripts:

package.json:

"scripts": {
  "test": "npx qunit-testrunner",
  "test:keepAlive": "npx qunit-testrunner --keepalive",
  "test:cov": "npx qunit-testrunner --cov",
  "coverage": "nyc report",
  "coverage:html": "nyc report --reporter=lcov && open-cli coverage/lcov-report/index.html"
}

Coverage measurement description

  1. Source files are instrumented when they are requested. --coverage-instrument-spec defines the pattern.
  2. QUnit.done event listener is injected into test .html files. Injector injects into every files based on --spec pattern and puts event handler after <head>
  3. Handler post __coverage__ result back to /__coverage__/[original path], like /test/foo/bar.html -> /__coverage__/foo/bar.html.
  4. istanbulCoverage middleware collects coverage results and saves them into the directory provided by --coverage-output-dir. The file name is an md5 hash generated from coverage url.
  5. nyc can generate coverage report based on coverage measurement. nyc report or nyc report --reporter=lcov

Small hack that generates empty coverage objects, so report will show totally uncovered files as well: npx nyc --instrument --include <src glob> --all --silent echo