Allure Store

raw JSON →
1.2.0 verified Sun Apr 19 auth: no javascript

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.

error TypeError: require is not a function
cause Attempting to use CommonJS `require()` syntax in a module that is ESM-only or within an ESM context.
fix
Update your import statements to use ES module syntax: 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'
cause The specified `allure-results` directory does not exist at the given path when calling `fromDirectory`.
fix
Verify the path to your Allure results directory is correct and that the directory actually exists. Create it if you intend to write to it and it's missing, or ensure a test runner has generated results there.
error TypeError: store.writeEnvironmentInfo is not a function
cause The `AllureStore` instance was created in a read-only mode or you are attempting to call a write method on an interface that only supports reading (e.g., a custom `AllureReader` implementation that doesn't also implement `AllureWriter`).
fix
Ensure you are using a store initialized with write capabilities, such as fromDirectory, and if overwriting is intended for an existing directory, pass { overwrite: true } in options for fromDirectory.
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.
fix Monitor GitHub repository for updates and breaking changes. Consider this for non-critical parts of your infrastructure initially.
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.
fix Ensure your Node.js environment is updated to version 16.14.0 or newer (e.g., using `nvm install 16` or `nvm use 16`).
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.
fix Initialize the store with `await fromDirectory('output-dir', { overwrite: true });` if you intend to replace or fully update existing data in the target directory.
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.
fix Review any custom `Category` type implementations or data structures after upgrading to `v1.1.1` or later to ensure compatibility with the refined type definitions.
npm install allure-store
yarn add allure-store
pnpm add allure-store

This quickstart demonstrates how to initialize an AllureStore from an existing `allure-results` directory, retrieve various Allure test data (all results, latest results, categories), and also shows how to write new environment information to a specified output directory.

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');
})();