Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,12 @@ class ResembleHelper extends Helper {
const allure: any = require("codeceptjs").container.plugins("allure");

if (allure !== undefined && misMatch >= options.tolerance) {
allure.addAttachment("Base Image", fs.readFileSync(this._getBaseImagePath(baseImage, options)), "image/png");
allure.addAttachment("Screenshot Image", fs.readFileSync(this._getActualImagePath(baseImage)), "image/png");
allure.addAttachment("Diff Image", fs.readFileSync(this._getDiffImagePath(baseImage)), "image/png");
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" }),
Comment on lines +238 to +240
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.

);
Comment on lines +236 to +241
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.

}
}

Expand Down