Registry / testing / allure-js-parser

allure-js-parser

JSON →
library0.1.0jsnpmunverified

allure-js-parser is a utility library designed to programmatically parse raw `allure-results` JSON files, typically generated by test frameworks that integrate with Allure Report. It converts these raw files into a structured, strongly typed JavaScript object, providing developers with a flexible foundation to analyze test outcomes, generate custom reports, calculate statistics, or integrate Allure data into other systems. The package is currently at version 0.1.0, indicating it's in its initial development phase, and has seen frequent patch and minor updates, reflecting active maintenance. Its primary differentiator is offering direct, typed programmatic access to Allure data for custom processing workflows, as opposed to relying solely on the standard Allure CLI for static report generation.

npm install allure-js-parser
INSTALL
IMPORT
SIG · ALLURE-JS-PARSER
A
allure-js-parser
testingjavascriptv0.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parseAllure
import { parseAllure } from 'allure-js-parser';
const { parseAllure } = require('allure-js-parser');
The library primarily uses ES Module syntax. While CommonJS might work via transpilation, direct require() is less idiomatic and potentially problematic in some environments.
AllureTestResult
import type { AllureTestResult } from 'allure-js-parser';
This is a representative type for the parsed test objects. The library ships with TypeScript types, allowing for strong typing when working with the parsed results.
AllureResult
import type { AllureResult } from 'allure-js-parser';
This type represents the overall structure of the parsed Allure results, often an array of `AllureTestResult`.

This quickstart demonstrates how to parse Allure result files from a specified directory, filter tests by labels, and extract basic statistics. It creates temporary Allure JSON files for a runnable example.

import { parseAllure } from 'allure-js-parser'; import * as path from 'path'; import * as fs from 'fs'; // Create a dummy 'allure-results' directory for demonstration const resultsDir = path.join(__dirname, 'temp-allure-results'); if (!fs.existsSync(resultsDir)) { fs.mkdirSync(resultsDir); } // Create a dummy Allure test result file fs.writeFileSync( path.join(resultsDir, 'test-result-123.json'), JSON.stringify({ uuid: 'test-result-123', name: 'Example Test', status: 'passed', labels: [{ name: 'tag', value: 'regression' }], start: Date.now() - 1000, stop: Date.now() }) ); fs.writeFileSync( path.join(resultsDir, 'test-result-456.json'), JSON.stringify({ uuid: 'test-result-456', name: 'Another Test', status: 'failed', labels: [{ name: 'tag', value: 'smoke' }], start: Date.now() - 2000, stop: Date.now() - 500 }) ); try { const tests = parseAllure(resultsDir); console.log(`Parsed ${tests.length} tests.`); // Filter tests with the 'regression' tag const regressionTests = tests.filter(t => t.labels.some(label => label.name === 'tag' && label.value === 'regression')); console.log(`Found ${regressionTests.length} regression tests: ${regressionTests.map(t => t.name).join(', ')}`); // Basic statistics const passedTests = tests.filter(t => t.status === 'passed').length; const failedTests = tests.filter(t => t.status === 'failed').length; console.log(`Total Passed: ${passedTests}, Total Failed: ${failedTests}`); } catch (error) { console.error('Error parsing Allure results:', error); } finally { // Clean up the dummy directory fs.rmSync(resultsDir, { recursive: true, force: true }); }
Debug
Known issues
gotchaThe package is currently in a 0.x.x version range. While actively developed, this implies that the API may not be fully stable and could introduce breaking changes in minor versions without adhering strictly to semantic versioning until a 1.0.0 release.
fix
Always pin to exact versions (e.g., `"allure-js-parser": "0.1.0"`) or use caret ranges carefully, and review changelogs for each update.
affects: >=0.0.1
gotchaThe `parseAllure` function expects a path to a directory containing the raw Allure JSON files. Providing a path to an individual file or a non-existent directory will result in errors.
fix
Ensure the path passed to `parseAllure` is a valid, existing directory that contains the `allure-results` JSON files.
affects: >=0.0.1
breakingVersion 0.1.0 introduced an option to `not log error when empty results` via a minor change. While not a direct breaking API change for existing calls, it signifies a new configurable behavior around error handling for empty results that users might want to be aware of and potentially configure.
fix
Review the latest documentation for `parseAllure` options if you need to suppress or customize error logging for scenarios where the results directory is empty or contains no valid Allure files.
affects: >=0.1.0
Errors
Common errors & fixes
Error: ENOENT: no such file or directory, scandir '/path/to/non-existent-allure-results'
The directory path provided to `parseAllure` does not exist on the file system.
fix
Verify that the path provided to `parseAllure` is correct and the directory exists. Ensure your test runner has generated Allure results in the specified location.
SyntaxError: Unexpected token 'X', "..." is not valid JSON
One or more of the files within the `allure-results` directory are malformed JSON.
fix
Inspect the JSON files in your `allure-results` directory for syntax errors. This often indicates an issue during the Allure result generation process by your test framework.
TypeError: parseAllure is not a function
This typically occurs when trying to import `parseAllure` using CommonJS `require()` syntax in an environment where the package is compiled for ESM, or vice-versa, or due to a typo in the import.
fix
Ensure you are using `import { parseAllure } from 'allure-js-parser';` for ESM projects. For CommonJS, if support is available, ensure correct destructuring, though ESM is preferred.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
67 hits · last 30 days
node
56
OpenAI (training)
1
Resources
allure-js-parser — npm install allure-js-parser · libregistry