Skip to content

Commit ad720cb

Browse files
committed
fix: Fix writing binary PNG content to screenshot files
1 parent b6fb73c commit ad720cb

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

tasks/html-dom-snapshot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ module.exports = function (grunt) {
291291
return ensureDirectory(screenshots)
292292
.then(function () {
293293
return new Promise(function (resolve, reject) {
294-
fs.writeFile(target, png, function (error) {
294+
fs.writeFile(target, new Buffer(png.value, 'base64'), function (error) {
295295
if (error) {
296296
reject(error);
297297
} else {

test/test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ exports['html-dom-snapshot'] = {
2525

2626
'static': function (test) {
2727
const snapshot = fs.existsSync('test/snapshots/static.html'),
28-
screenshot = fs.readFileSync('test/screenshots/static.png');
28+
screenshot = fs.statSync('test/screenshots/static.png');
2929
test.ok(!snapshot, 'static.html');
30-
test.ok(screenshot, 'static.png');
30+
test.ok(screenshot.size > 1024, 'static.png');
3131
test.done();
3232
},
3333

@@ -41,9 +41,9 @@ exports['html-dom-snapshot'] = {
4141
'dynamic': function (test) {
4242
const pages = readPages('dynamic.html'),
4343
expected = pages.expected.replace('<body>', '<body class="dynamic">'),
44-
screenshot = fs.readFileSync('test/screenshots/dynamic.png');
44+
screenshot = fs.statSync('test/screenshots/dynamic.png');
4545
test.equal(expected, pages.actual, 'dynamic.html');
46-
test.ok(screenshot, 'dynamic.png');
46+
test.ok(screenshot.size > 1024, 'dynamic.png');
4747
test.done();
4848
},
4949

0 commit comments

Comments
 (0)