Allure Store
raw JSON →allure-store provides a flexible and extensible data store for interacting with Allure test results. It offers a unified API, the AllureStore, to read, write, and transform various Allure data entities like test results, containers, categories, environment information, and executor details. The library supports reading from traditional `allure-results` directories, as well as compiled Allure2 reports (local directories, HTML files, or HTTP/HTTPS URLs), and allows writing data back. It is currently at version 1.2.0, with a relatively active release cadence since its initial release in late 2024, focusing on feature enhancements and bug fixes. Key differentiators include its pluggable `AllureReader` and `AllureWriter` interfaces, enabling custom storage backends and result aggregation capabilities, making it highly adaptable for CI/CD pipelines or custom reporting tools.
Common errors
error TypeError: require is not a function ↓
import { fromDirectory } from 'allure-store'; and ensure your project is configured for ESM (e.g., "type": "module" in package.json). error ENOENT: no such file or directory, scandir 'allure-results' ↓
error TypeError: store.writeEnvironmentInfo is not a function ↓
fromDirectory, and if overwriting is intended for an existing directory, pass { overwrite: true } in options for fromDirectory. Warnings
gotcha The project is housed under `wix-incubator` on GitHub, indicating it might be an experimental or early-stage project. While actively maintained, users should be aware of its incubation status regarding long-term support guarantees or potential breaking changes in minor versions. ↓
gotcha This package requires Node.js version 16.14.0 or higher. Running it with older Node.js versions will result in runtime errors due to unsupported syntax or APIs. ↓
gotcha When using `fromDirectory` to write data, if the target directory already exists and you intend to overwrite its contents, you *must* pass `{ overwrite: true }` in the options. Failing to do so might prevent new data from being written or merged as expected. ↓
breaking Version 1.1.1 included a fix for erroneous properties in the `Category` type. If you were working with custom categories in versions <=1.1.0, your category definitions or consumption might need minor adjustments to align with the corrected type definition. ↓
Install
npm install allure-store yarn add allure-store pnpm add allure-store Imports
- fromDirectory wrong
const { fromDirectory } = require('allure-store');correctimport { fromDirectory } from 'allure-store'; - fromReport wrong
const fromReport = require('allure-store').fromReport;correctimport { fromReport } from 'allure-store'; - AllureStore
import type { AllureStore } from 'allure-store';
Quickstart
import { fromDirectory } from 'allure-store';
(async () => {
// Ensure 'allure-results' directory exists and contains Allure data
const store = await fromDirectory('allure-results');
// Retrieve all test results found in the store
const allResults = await store.getAllResults();
console.log('Total test results:', allResults.length);
if (allResults.length > 0) {
console.log('First result name:', allResults[0].name);
}
// Get the latest results, useful for history tracking
const latestResults = await store.getLatestResults();
console.log('Latest results per historyId:', Object.keys(latestResults).length);
// Fetch defined categories
const categories = await store.getCategories();
console.log('Categories loaded:', categories);
// Example of writing environment info (requires overwrite: true in fromDirectory if directory exists)
const writeStore = await fromDirectory('allure-results-output', { overwrite: true });
await writeStore.writeEnvironmentInfo({
NODE_ENV: process.env.NODE_ENV ?? 'development',
BUILD_ID: process.env.BUILD_ID ?? 'local-build'
});
console.log('Environment info written to allure-results-output');
})();