{"id":15508,"library":"allure-js-parser","title":"Allure JS Parser","description":"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.","status":"active","version":"0.1.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/mmisty/allure-js-parser","tags":["javascript","typescript"],"install":[{"cmd":"npm install allure-js-parser","lang":"bash","label":"npm"},{"cmd":"yarn add allure-js-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add allure-js-parser","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The library primarily uses ES Module syntax. While CommonJS might work via transpilation, direct require() is less idiomatic and potentially problematic in some environments.","wrong":"const { parseAllure } = require('allure-js-parser');","symbol":"parseAllure","correct":"import { parseAllure } from 'allure-js-parser';"},{"note":"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.","symbol":"AllureTestResult","correct":"import type { AllureTestResult } from 'allure-js-parser';"},{"note":"This type represents the overall structure of the parsed Allure results, often an array of `AllureTestResult`.","symbol":"AllureResult","correct":"import type { AllureResult } from 'allure-js-parser';"}],"quickstart":{"code":"import { parseAllure } from 'allure-js-parser';\nimport * as path from 'path';\nimport * as fs from 'fs';\n\n// Create a dummy 'allure-results' directory for demonstration\nconst resultsDir = path.join(__dirname, 'temp-allure-results');\nif (!fs.existsSync(resultsDir)) {\n  fs.mkdirSync(resultsDir);\n}\n\n// Create a dummy Allure test result file\nfs.writeFileSync(\n  path.join(resultsDir, 'test-result-123.json'),\n  JSON.stringify({\n    uuid: 'test-result-123',\n    name: 'Example Test',\n    status: 'passed',\n    labels: [{ name: 'tag', value: 'regression' }],\n    start: Date.now() - 1000,\n    stop: Date.now()\n  })\n);\n\nfs.writeFileSync(\n  path.join(resultsDir, 'test-result-456.json'),\n  JSON.stringify({\n    uuid: 'test-result-456',\n    name: 'Another Test',\n    status: 'failed',\n    labels: [{ name: 'tag', value: 'smoke' }],\n    start: Date.now() - 2000,\n    stop: Date.now() - 500\n  })\n);\n\ntry {\n  const tests = parseAllure(resultsDir);\n  console.log(`Parsed ${tests.length} tests.`);\n\n  // Filter tests with the 'regression' tag\n  const regressionTests = tests.filter(t => t.labels.some(label => label.name === 'tag' && label.value === 'regression'));\n  console.log(`Found ${regressionTests.length} regression tests: ${regressionTests.map(t => t.name).join(', ')}`);\n\n  // Basic statistics\n  const passedTests = tests.filter(t => t.status === 'passed').length;\n  const failedTests = tests.filter(t => t.status === 'failed').length;\n  console.log(`Total Passed: ${passedTests}, Total Failed: ${failedTests}`);\n} catch (error) {\n  console.error('Error parsing Allure results:', error);\n} finally {\n  // Clean up the dummy directory\n  fs.rmSync(resultsDir, { recursive: true, force: true });\n}\n","lang":"typescript","description":"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."},"warnings":[{"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.","message":"The 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.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Ensure the path passed to `parseAllure` is a valid, existing directory that contains the `allure-results` JSON files.","message":"The `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.","severity":"gotcha","affected_versions":">=0.0.1"},{"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.","message":"Version 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.","severity":"breaking","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"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.","cause":"The directory path provided to `parseAllure` does not exist on the file system.","error":"Error: ENOENT: no such file or directory, scandir '/path/to/non-existent-allure-results'"},{"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.","cause":"One or more of the files within the `allure-results` directory are malformed JSON.","error":"SyntaxError: Unexpected token 'X', \"...\" is not valid JSON"},{"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.","cause":"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.","error":"TypeError: parseAllure is not a function"}],"ecosystem":"npm"}