Skip to content

CucumberJS: application/vnd.allure.playwright-trace attachment not linked in After hook #1386

@bionikokex

Description

@bionikokex

Describe the bug
In the repro project (branch attachment-with-trace-type), when using @cucumber/cucumber + allure-cucumberjs/reporter + allure-js-commons, a Playwright trace (zip) attached with content type application/vnd.allure.playwright-trace via attachment()/attachmentPath() is not referenced in the generated allure-results/*-result.json when the attach call is executed in a Cucumber After hook.
The same trace attachment becomes referenced in *-result.json when the attach is executed from AfterStep (e.g. on FAILED step).
Repro repository/branch: https://github.com/bionikokex/allure/tree/attachment-with-trace-type

To Reproduce
Steps to reproduce the behavior:

  1. Clone repo and checkout branch:
git clone https://github.com/bionikokex/allure.git
cd allure && git checkout attachment-with-trace-type
  1. Install dependencies:
    node 24+
yarn install
  1. Run the tagged scenario:
yarn cucumber-js --tags @attach
  1. Observe the results:
  • Attachment file(s) may appear in allure-results (e.g. *-attachment.zip), but
  • allure-results/*-result.json contains "attachments": [] for the test and steps when the trace attachment is added in After.
  1. Switch hooks to the AfterStep implementation (attach on failed step) and rerun:
  • Now allure-results/*-result.json includes the attachment reference (typically under a nested step like "steps" -> "steps" -> "attachments").

Expected behavior

When calling attachment() / attachmentPath() with content type application/vnd.allure.playwright-trace inside a Cucumber After hook, the attachment should be referenced in *-result.json (either at the test level or as an after-fixture/after-step entity), similarly to how it works from AfterStep.

Desktop (please complete the following information)

  • OS: Windows 11
  • Node.js: v24.4.1
  • @cucumber/cucumber: 12.4.0
  • allure-cucumberjs: 3.4.3
  • allure-js-commons: 3.4.3
  • playwright: 1.56.1

Additional context

  • The trace zip is generated correctly by Playwright (context.tracing.stop({ path })), so the issue seems to be about how the Allure runtime binds attachments to the current test/step context in Cucumber lifecycle hooks.
  • The issue is specific to the trace mime type application/vnd.allure.playwright-trace and the After hook; AfterStep works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions