QUnit Test Output Parser
The `qunit-parser` package is a JavaScript utility designed to parse the raw text output from the QUnit testing framework, aiming to provide a structured, programmatic representation of test results. Currently at version 0.2.0, this package was last published approximately seven years ago, indicating it is an abandoned project with no ongoing maintenance or updates. It is not affiliated with the core QUnit testing framework itself but rather serves a niche function for processing CLI or log output. Due to its age, users should be aware of potential incompatibilities with newer QUnit versions or modern JavaScript environments. Its release cadence is non-existent, and its primary utility lies in attempting to extract data from QUnit's console output where other programmatic interfaces might not be feasible.
Warnings
- breaking This package is effectively abandoned, with its last publish occurring over seven years ago. There are no recent updates, bug fixes, or security patches. It is highly unlikely to be compatible with modern QUnit versions, Node.js runtimes, or contemporary JavaScript module systems without significant intervention or polyfills.
- gotcha Due to its age, `qunit-parser` was written for CommonJS environments. Attempting to use ES Modules (`import`) directly will likely result in a `TypeError: require is not a function` or similar module resolution errors in modern Node.js environments configured for ESM, or build failures in bundlers.
- gotcha Parsing raw console output is inherently brittle. The `qunit-parser` likely relies on specific output formats from QUnit that may have changed significantly over time. Any minor change in QUnit's console reporter format (e.g., different wording, new lines, different formatting of objects) could break the parser entirely, leading to incorrect or incomplete results.
Install
-
npm install qunit-parser -
yarn add qunit-parser -
pnpm add qunit-parser
Imports
- parse
import { parse } from 'qunit-parser';const { parse } = require('qunit-parser');
Quickstart
const { parse } = require('qunit-parser');
// Simulate a simplified QUnit console output string
const qunitOutput = `
Running 2 tests
ok 1 - My Module > Test 1: should pass
# pass 1
# fail 0
not ok 2 - My Module > Test 2: should fail an assertion
# test timed out
# {
# "name": "My Module > Test 2: should fail an assertion",
# "passed": 0,
# "failed": 1,
# "total": 1,
# "duration": 50,
# "errors": ["Assertion failed: expected true, got false"],
# "seed": "12345"
# }
1..2
# tests 2
# pass 1
# fail 1
`;
try {
const parsedResults = parse(qunitOutput);
console.log('Parsed QUnit Results:');
console.log(JSON.stringify(parsedResults, null, 2));
// Example of accessing parsed data
console.log(`Total tests: ${parsedResults.total}`);
console.log(`Passed tests: ${parsedResults.passed}`);
console.log(`Failed tests: ${parsedResults.failed}`);
if (parsedResults.failures && parsedResults.failures.length > 0) {
console.log('Details of first failure:', parsedResults.failures[0]);
}
} catch (error) {
console.error('Error parsing QUnit output:', error.message);
}