Skip to content

Conversation

Raytek
Copy link

@Raytek Raytek commented Jan 11, 2024

This PR aims to add support to allure screen diff plugin.

resolves #70
resolves #58

@kobenguyent kobenguyent changed the title Allure screen diff plugin support feat(allure): screen diff plugin support Jan 23, 2024
@kobenguyent kobenguyent requested review from Copilot and thomashohn and removed request for sharath2106 October 4, 2025 14:09
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds Allure screen-diff plugin support by changing how screenshots are attached when a visual mismatch exceeds tolerance.

  • Replace three image attachments with a single allure.addScreenDiff call.
  • Switch from Buffer attachments to base64-encoded strings.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +236 to +241
allure.addScreenDiff(
"Screen Diff",
fs.readFileSync(this._getBaseImagePath(baseImage, options), { encoding: "base64" }),
fs.readFileSync(this._getActualImagePath(baseImage), { encoding: "base64" }),
fs.readFileSync(this._getDiffImagePath(baseImage), { encoding: "base64" }),
);
Copy link
Preview

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeceptJS's Allure plugin does not expose addScreenDiff in supported versions; calling this will throw at runtime. Use standard attachments with the names expected by the Allure screen-diff plugin (expected, actual, diff), or feature-detect and fall back to addAttachment.

Suggested change
allure.addScreenDiff(
"Screen Diff",
fs.readFileSync(this._getBaseImagePath(baseImage, options), { encoding: "base64" }),
fs.readFileSync(this._getActualImagePath(baseImage), { encoding: "base64" }),
fs.readFileSync(this._getDiffImagePath(baseImage), { encoding: "base64" }),
);
allure.addAttachment(
"expected",
fs.readFileSync(this._getBaseImagePath(baseImage, options)),
"image/png"
);
allure.addAttachment(
"actual",
fs.readFileSync(this._getActualImagePath(baseImage)),
"image/png"
);
allure.addAttachment(
"diff",
fs.readFileSync(this._getDiffImagePath(baseImage)),
"image/png"
);

Copilot uses AI. Check for mistakes.

Comment on lines +238 to +240
fs.readFileSync(this._getBaseImagePath(baseImage, options), { encoding: "base64" }),
fs.readFileSync(this._getActualImagePath(baseImage), { encoding: "base64" }),
fs.readFileSync(this._getDiffImagePath(baseImage), { encoding: "base64" }),
Copy link
Preview

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading images as base64 strings increases memory/cpu and bloats attachments by ~33%. Prefer passing Buffers (omit the encoding option) to avoid unnecessary encoding and to keep report size smaller.

Suggested change
fs.readFileSync(this._getBaseImagePath(baseImage, options), { encoding: "base64" }),
fs.readFileSync(this._getActualImagePath(baseImage), { encoding: "base64" }),
fs.readFileSync(this._getDiffImagePath(baseImage), { encoding: "base64" }),
fs.readFileSync(this._getBaseImagePath(baseImage, options)),
fs.readFileSync(this._getActualImagePath(baseImage)),
fs.readFileSync(this._getDiffImagePath(baseImage)),

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Comparison different image didn't added in html test report. codeceptjs-resemblehelper and Allure Screen Diff Plugin
3 participants