@probe.gl/test-utils
Advanced tools
Comparing version 3.4.0 to 3.4.1
@@ -61,3 +61,5 @@ "use strict"; | ||
_config$headless = config.headless, | ||
headless = _config$headless === void 0 ? false : _config$headless; | ||
headless = _config$headless === void 0 ? false : _config$headless, | ||
_config$maxConsoleMes = config.maxConsoleMessageLength, | ||
maxConsoleMessageLength = _config$maxConsoleMes === void 0 ? MAX_CONSOLE_MESSAGE_LENGTH : _config$maxConsoleMes; | ||
this.title = title; | ||
@@ -67,2 +69,3 @@ this.headless = headless; | ||
this.failures = 0; | ||
this.maxConsoleMessageLength = maxConsoleMessageLength; | ||
this.logger.log({ | ||
@@ -154,4 +157,8 @@ message: "".concat(title), | ||
var text = event.text().slice(0, MAX_CONSOLE_MESSAGE_LENGTH); | ||
var text = event.text(); | ||
if (!text.startsWith('data:')) { | ||
text = text.slice(0, this.maxConsoleMessageLength); | ||
} | ||
switch (event.type()) { | ||
@@ -158,0 +165,0 @@ case 'log': |
@@ -58,4 +58,7 @@ "use strict"; | ||
includeEmpty = _options$includeEmpty === void 0 ? true : _options$includeEmpty; | ||
var diffImage = createDiffImage ? new Uint8Array(width * height) : null; | ||
var mismatchedPixels = (0, _pixelmatch.default)(image1.data, image2.data, diffImage, width, height, { | ||
var diffImage = new _pngjs.PNG({ | ||
width: width, | ||
height: height | ||
}); | ||
var mismatchedPixels = (0, _pixelmatch.default)(image1.data, image2.data, diffImage.data, width, height, { | ||
threshold: tolerance, | ||
@@ -66,7 +69,8 @@ includeAA: includeAA | ||
var match = 1 - mismatchedPixels / pixelCount; | ||
var success = match >= threshold; | ||
return { | ||
match: match, | ||
matchPercentage: "".concat((match * 100).toFixed(2), "%"), | ||
success: match >= threshold, | ||
diffImage: diffImage | ||
success: success, | ||
diffImage: !success && createDiffImage ? encodePNG(diffImage) : null | ||
}; | ||
@@ -116,2 +120,12 @@ } | ||
} | ||
function encodePNG(image) { | ||
if (!image) { | ||
return null; | ||
} | ||
var buffer = _pngjs.PNG.sync.write(image, {}); | ||
return "data:image/png;base64,".concat(buffer.toString('base64')); | ||
} | ||
//# sourceMappingURL=diff-images.js.map |
@@ -11,3 +11,4 @@ import BrowserDriver from './browser-driver'; | ||
title = 'Browser Test', | ||
headless = false | ||
headless = false, | ||
maxConsoleMessageLength = MAX_CONSOLE_MESSAGE_LENGTH | ||
} = config; | ||
@@ -18,2 +19,3 @@ this.title = title; | ||
this.failures = 0; | ||
this.maxConsoleMessageLength = maxConsoleMessageLength; | ||
this.logger.log({ | ||
@@ -82,4 +84,8 @@ message: "".concat(title), | ||
const text = event.text().slice(0, MAX_CONSOLE_MESSAGE_LENGTH); | ||
let text = event.text(); | ||
if (!text.startsWith('data:')) { | ||
text = text.slice(0, this.maxConsoleMessageLength); | ||
} | ||
switch (event.type()) { | ||
@@ -86,0 +92,0 @@ case 'log': |
@@ -32,4 +32,7 @@ import fs from 'fs'; | ||
} = options; | ||
const diffImage = createDiffImage ? new Uint8Array(width * height) : null; | ||
const mismatchedPixels = pixelmatch(image1.data, image2.data, diffImage, width, height, { | ||
const diffImage = new PNG({ | ||
width, | ||
height | ||
}); | ||
const mismatchedPixels = pixelmatch(image1.data, image2.data, diffImage.data, width, height, { | ||
threshold: tolerance, | ||
@@ -40,7 +43,8 @@ includeAA | ||
const match = 1 - mismatchedPixels / pixelCount; | ||
const success = match >= threshold; | ||
return { | ||
match, | ||
matchPercentage: "".concat((match * 100).toFixed(2), "%"), | ||
success: match >= threshold, | ||
diffImage | ||
success, | ||
diffImage: !success && createDiffImage ? encodePNG(diffImage) : null | ||
}; | ||
@@ -87,2 +91,11 @@ } | ||
} | ||
function encodePNG(image) { | ||
if (!image) { | ||
return null; | ||
} | ||
const buffer = PNG.sync.write(image, {}); | ||
return "data:image/png;base64,".concat(buffer.toString('base64')); | ||
} | ||
//# sourceMappingURL=diff-images.js.map |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "3.4.0", | ||
"version": "3.4.1", | ||
"keywords": [ | ||
@@ -31,6 +31,6 @@ "integration test", | ||
"pixelmatch": "^4.0.2", | ||
"probe.gl": "3.4.0", | ||
"probe.gl": "3.4.1", | ||
"puppeteer": "*" | ||
}, | ||
"gitHead": "3870d9be30372543514a759cb1e35b463852e721" | ||
"gitHead": "988375fec650185893d2bc240e74ac59eee85d2d" | ||
} |
@@ -30,3 +30,7 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc. | ||
run(config = {}) { | ||
const {title = 'Browser Test', headless = false} = config; | ||
const { | ||
title = 'Browser Test', | ||
headless = false, | ||
maxConsoleMessageLength = MAX_CONSOLE_MESSAGE_LENGTH | ||
} = config; | ||
this.title = title; | ||
@@ -36,2 +40,3 @@ this.headless = headless; | ||
this.failures = 0; | ||
this.maxConsoleMessageLength = maxConsoleMessageLength; | ||
@@ -115,3 +120,7 @@ this.logger.log({ | ||
// Crop very long text messages to avoid flooding | ||
const text = event.text().slice(0, MAX_CONSOLE_MESSAGE_LENGTH); | ||
let text = event.text(); | ||
if (!text.startsWith('data:')) { | ||
// Leave data URL intact so that we have a channel to get data out via console | ||
text = text.slice(0, this.maxConsoleMessageLength); | ||
} | ||
switch (event.type()) { | ||
@@ -118,0 +127,0 @@ case 'log': |
@@ -35,3 +35,3 @@ import fs from 'fs'; | ||
const diffImage = createDiffImage ? new Uint8Array(width * height) : null; | ||
const diffImage = new PNG({width, height}); | ||
@@ -42,3 +42,3 @@ // pixelmatch returns the number of mismatched pixels | ||
image2.data, // image 2 | ||
diffImage, // output | ||
diffImage.data, // output | ||
width, // width | ||
@@ -52,2 +52,3 @@ height, // height | ||
const match = 1 - mismatchedPixels / pixelCount; | ||
const success = match >= threshold; | ||
@@ -57,4 +58,4 @@ return { | ||
matchPercentage: `${(match * 100).toFixed(2)}%`, | ||
success: match >= threshold, | ||
diffImage | ||
success, | ||
diffImage: !success && createDiffImage ? encodePNG(diffImage) : null | ||
}; | ||
@@ -100,1 +101,9 @@ } | ||
} | ||
function encodePNG(image) { | ||
if (!image) { | ||
return null; | ||
} | ||
const buffer = PNG.sync.write(image, {}); | ||
return `data:image/png;base64,${buffer.toString('base64')}`; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
176095
2465
+ Added@probe.gl/stats@3.4.1(transitive)
+ Addedprobe.gl@3.4.1(transitive)
- Removed@probe.gl/stats@3.4.0(transitive)
- Removedprobe.gl@3.4.0(transitive)
Updatedprobe.gl@3.4.1