@codeceptjs/allure-legacy

中文文档
1.0.2发布于 2023/02/15ISCCommonJS近 30 天下载 7.1万

Allure plugin for CodeceptJS

原始使用文档
文档目录16 节
  1. addAttachment
  2. Parameters
  3. addLabel
  4. Parameters
  5. addParameter
  6. Parameters
  7. addScreenDiff
  8. Parameters
  9. createStep
  10. Parameters
  11. setDescription
  12. Parameters
  13. allure
  14. Parameters
  15. allure
  16. Parameters

Allure Plugin

Allure plugin for CodeceptJS via allure-commons v1

Warning This plugin was deprecated in CodeceptJS as to allure-commons v1 was not maintained anymore. Documentation and source code was moved into this repository. At this moment we don't plan to migrate it to Allure v2 but community can create their own implementations

Enables Allure reporter.

Usage

To start please install allure-commandline package (which requires Java 8)

npm install -g allure-commandline --save-dev

Add this plugin to config file:

plugins: {
  allure: {
    enabled: true,
    require: '@codeceptjs/allure-legacy',
  }
}

By default, allure reports are saved to output directory. Launch Allure server and see the report like on a screenshot above:

allure serve output

Configuration

  • outputDir - a directory where allure reports should be stored. Standard output directory is set by default.
  • enableScreenshotDiffPlugin - a boolean flag for add screenshot diff to report. To attach, tou need to attach three files to the report - "diff.png", "actual.png", "expected.png". See Allure Screenshot Plugin

Public API

There are few public API methods which can be accessed from other plugins.

const allure = codeceptjs.container.plugins('allure');

allure object has following methods:

  • addAttachment(name, buffer, type) - add an attachment to current test / suite
  • addLabel(name, value) - adds a label to current test
  • addParameter(kind, name, value) - adds a parameter to current test
  • createStep(name, stepFunc) - create a step, stepFunc could consist an attachment Example of usage:
    allure.createStep('New created step', () => {
      allure.addAttachment(
        'Request params',
        '{"clientId":123, "name":"Tom", "age":29}',
        'application/json'
      );
    });

Created Step Image

  • addScreenDiff(name, expectedImg, actualImg, diffImg) - add a special screen diff block to the current test case image must be a string representing the contents of the expected image file encoded in base64 Example of usage:
const expectedImg = fs.readFileSync('expectedImg.png', { encoding: 'base64' });
...
allure.addScreenDiff('Screen Diff', expectedImg, actualImg, diffImg);

Overlay Diff

  • severity(value) - adds severity label
  • epic(value) - adds epic label
  • feature(value) - adds feature label
  • story(value) - adds story label
  • issue(value) - adds issue label
  • setDescription(description, type) - sets a description

addAttachment

Add an attachment to the current test case

Parameters

  • name [string][1] Name of the attachment
  • buffer [Buffer][2] Buffer of the attachment
  • type [string][1] MIME type of the attachment

addLabel

Adds a label with the given name and value to the current test in the Allure report

Parameters

  • name [string][1] name of the label to add
  • value [string][1] value of the label to add

addParameter

Adds a parameter with the given kind, name, and value to the current test in the Allure report

Parameters

  • kind [string][1] kind of the parameter to add
  • name [string][1] name of the parameter to add
  • value [string][1] value of the parameter to add

addScreenDiff

Add a special screen diff block to the current test case

Parameters

  • name [string][1] Name of the screen diff block
  • expectedImg [string][1] string representing the contents of the expected image file encoded in base64
  • actualImg [string][1] string representing the contents of the actual image file encoded in base64
  • diffImg [string][1] string representing the contents of the diff image file encoded in base64. Could be generated by image comparison lib like "pixelmatch" or alternative

createStep

A method for creating a step in a test case.

Parameters

  • name [string][1] The name of the step.
  • stepFunc [Function][3] The function that should be executed for this step. (optional, default ()=>{})

Returns any The result of the step function.

setDescription

Set description for the current test case

Parameters

  • description [string][1] Description for the test case
  • type [string][1] MIME type of the description (optional, default 'text/plain')

allure

Allure reporter

![][4]

Parameters

  • config

allure

Creates an instance of the allure reporter

Parameters

  • config Config Configuration for the allure reporter (optional, default {outputDir:global.output_dir})

Returns [Object][9] Instance of the allure reporter

版本与发布记录

@codeceptjs/allure-legacy 共发布 3 个版本,首次发布于 2023/02/15;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.2latest2023/02/153 年前
1.0.12023/02/153 年前
1.0.02023/02/153 年前

关于 @codeceptjs/allure-legacy 的常见问题

@codeceptjs/allure-legacy 是什么?

Allure plugin for CodeceptJS

如何安装 @codeceptjs/allure-legacy?

在项目目录运行 npm install @codeceptjs/allure-legacy,或使用 pnpm add / yarn add / bun add。

@codeceptjs/allure-legacy 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/codeceptjs__allure-legacy 是否存在。

@codeceptjs/allure-legacy 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@codeceptjs/allure-legacy 可以商用吗?

@codeceptjs/allure-legacy 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@codeceptjs/allure-legacy 的下载量有多少?

根据 npm 官方下载统计,@codeceptjs/allure-legacy 在 2026/10/10 – 2026/11/08 这 30 天内被下载 71,120 次,日均约 2,371 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@codeceptjs/allure-legacy 还在维护吗?

最新版本 1.0.2 发布于 2023/02/15(3 年前);至今共发布 3 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/02/15。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。