feat(allure): screen diff plugin support#134
feat(allure): screen diff plugin support#134Raytek wants to merge 8 commits intocodeceptjs:masterfrom
Conversation
There was a problem hiding this comment.
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.
| 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" }), | ||
| ); |
There was a problem hiding this comment.
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.
| 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" | |
| ); |
| fs.readFileSync(this._getBaseImagePath(baseImage, options), { encoding: "base64" }), | ||
| fs.readFileSync(this._getActualImagePath(baseImage), { encoding: "base64" }), | ||
| fs.readFileSync(this._getDiffImagePath(baseImage), { encoding: "base64" }), |
There was a problem hiding this comment.
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.
| 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)), |
This PR aims to add support to allure screen diff plugin.
resolves #70
resolves #58