Skip to content

Commit d4bc14a

Browse files
Merge pull request #9 from kobenguyent/attach-diff-image-to-allure
feat: attach diff screenshot to allure report
2 parents 3ab317e + fd33a57 commit d4bc14a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ node_modules/
33

44
# Personal notes
55
local-notes.md
6+
7+
.idea
8+

index.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const fs = require('fs');
2-
const PNG = require('pngjs').PNG;
2+
const { PNG } = require('pngjs');
33
const pixelmatch = require('pixelmatch');
44
const path = require('path');
55
const Helper = require('@codeceptjs/helper');
@@ -39,7 +39,7 @@ class PixelmatchHelper extends Helper {
3939
};
4040

4141
/**
42-
* Default tolserance level for comparisons.
42+
* Default tolerance level for comparisons.
4343
*
4444
* @type {float}
4545
*/
@@ -1045,6 +1045,13 @@ class PixelmatchHelper extends Helper {
10451045
if (data && data instanceof Buffer) {
10461046
fs.writeFileSync(path, data);
10471047
}
1048+
1049+
// if allure is used, attached the diff screenshot
1050+
const allure = codeceptjs.container.plugins("allure");
1051+
if (allure) {
1052+
this.debug(`Attaching diff screenshot to Allure report...`);
1053+
allure.addAttachment(`${this.globalDiffPrefix}_screenshot.png`, data, "image/png");
1054+
}
10481055
}
10491056

10501057
/**

0 commit comments

Comments
 (0)