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

@slothsoft/qunit-reporter

v0.2.0

Published

A module to generate reports from QUnit.

Downloads

80

Readme

QUnit Reporter

MIT Licence Build Status npm version

A module to generate reports from QUnit. Right now this module supports getting test data from multiple sources. Similarly it exports into different formats.

Content of this file:

Getting Started

Installing

This module can be found in the npm software registry:

npm install @slothsoft/qunit-reporter --save

Using the Framework

Creating a test report consists of two parts:

  1. Collecting the test results
  2. Exporting the collected results

The general API to mix and match both parts is:

var sourceConfig = {};
var exportConfig = {};

require("@slothsoft/qunit-reporter")
	.from<Source>(sourceConfig)
	.to<Export>(exportConfig);

You can generally chain multiple exports after each other like this:

require("@slothsoft/qunit-reporter")
	.from<Source>(sourceConfig)
	.to<Export1>(exportConfig)
	.to<Export2>(exportConfig)
	.to<Export3>(exportConfig);

Examples for Sources

QUnit

const QUnit = require("qunit");

QUnit.module("source-qunit", function() {
	QUnit.test("my first test", function(assert) {
		assert.equal(true, true);
	});
});

require("@slothsoft/qunit-reporter").fromQUnit().toLog({ file : "example/output/source-qunit.txt" });

Custom Source

var run = {
	name : "Run",
	suites : [
		{
			name : "source-run",
			tests : [
				{ name : "Test 1", time : 123},
				{ name : "Test 2", time : 456, error : "Error"},
				{ name : "Test 3", time : 789, failure : "Failure"},
			],
		}
	],
	total : 3,
	failures : 1,
	errors : 1,
	tile : 1368
};

require("@slothsoft/qunit-reporter").fromRun(run).toLog({ file : "example/output/source-run.txt" });

Examples for Exports

All exports acknowledge the following parameters in their configuration:

  • file - exports directly to file
  • callback - callback function with report content

HTML

Creates an HTML that can be displayed in any browser.

var run = createRun();

require("@slothsoft/qunit-reporter").fromRun(run).toHtml({
	file : "example/output/export-html.html", // exports directly to file
	callback : reportContent => {}, // callback function with report content
	encoding : 'utf-8', // the encoding of the exported file
	xsl : null, // XSL that converts to HTML (or whatever you like)
	xslFile : null, // path to XSL file that converts to HTML
});

To see how the config for XSL might work see this example:

JUnit

Creates standard JUnit XML that should be readable by every program that can handle JUnit as well.

var run = createRun();

require("@slothsoft/qunit-reporter").fromRun(run).toJUnit({
	file : "example/output/export-junit.xml", // exports directly to file
	callback : reportContent => {}, // callback function with report content
	encoding : 'utf-8', // the encoding of the exported file
});

Log

Creates a log similar to what NodeJS does when executing the tests.

var run = createRun();

require("@slothsoft/qunit-reporter").fromRun(run).toLog({
	file : "example/output/export-log.txt", // exports directly to file
	callback : reportContent => {}, // callback function with report content
	encoding : 'utf-8', // the encoding of the exported file
});

Custom Export

Uses a function to export the run.

var run = createRun();

require("@slothsoft/qunit-reporter").fromRun(run).toCustomExport(function(run) {
	// this is a minimalistic report
	return (run.total - run.failures - run.errors) + " / " + run.total + " passed.";
}, {
	file : "example/output/export-custom.txt", // exports directly to file
	callback : reportContent => {}, // callback function with report content
	encoding : 'utf-8', // the encoding of the exported file
});

Versions

| Version | Release Notes | | ------------- | ---------------- | | 0.2.0 | XSL for HTML works correctly now and is customizablebugfixesdefensive programming | | 0.1.0 | basic functionalitysources: QUnitexports: JUnit, HTML |

License

This project is licensed under the MIT License - see the MIT license for details.