Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

puppeteer-screenshot-tester

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

puppeteer-screenshot-tester - npm Package Compare versions

Comparing version 1.5.0 to 1.6.0

2

package.json
{
"name": "puppeteer-screenshot-tester",
"version": "1.5.0",
"version": "1.6.0",
"description": "Small library that allows us to compare screenshots generated by puppeteer in our tests",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -5,4 +5,6 @@ puppeteer-screenshot-tester

<p align="center">
<a href="https://nodejs.org/docs/latest-v12.x/api/index.html"><img src="https://img.shields.io/badge/node-12+-brightgreen.svg"></a>
<a href="https://nodejs.org/docs/latest-v12.x/api/index.html"><img src="https://img.shields.io/node/v-lts/puppeteer-screenshot-tester"></a>
<a href="https://www.npmjs.com/package/puppeteer-screenshot-tester"><img src="https://img.shields.io/npm/v/puppeteer-screenshot-tester.svg"></a>
<a href="https://www.npmjs.com/package/puppeteer"><img src="https://img.shields.io/npm/dependency-version/puppeteer-screenshot-tester/dev/puppeteer"></a>
<a href="https://www.npmjs.com/package/puppeteer"><img alt="npm" src="https://img.shields.io/npm/dt/puppeteer-screenshot-tester?color=purple"></a>
</p>

@@ -69,2 +71,3 @@

compressionLevel: 8 // 0-9 for .png, 0-100 otherwise
overrides: {} // valid sharp options (see bellow)
}

@@ -74,2 +77,9 @@ ```

#### overrides:
You can override options passed to [sharp image processor](https://sharp.pixelplumbing.com/). Just paste the `overrides` object that corresponds with sharp options:
- .png [Options](https://sharp.pixelplumbing.com/api-output#png)
- .webp [Options](https://sharp.pixelplumbing.com/api-output#webp)
- .jpeg/jpg [Options](https://sharp.pixelplumbing.com/api-output#jpeg)
### Run the test

@@ -185,2 +195,2 @@

This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!

@@ -30,3 +30,4 @@ const resemble = require('nodejs-resemble');

forceExt: null,
compressionLevel: null
compressionLevel: null,
overrides: {}
}) {

@@ -91,7 +92,8 @@ if(Array.isArray(matchingBox)) {

const storeExt = outputSettings.forceExt != null ? outputSettings.forceExt : ext.substring(ext.lastIndexOf(".")+1);
const overrides = outputSettings.overrides || {};
const extFormatter = {
'jpeg': () => sharp().jpeg({ quality: outputSettings.compressionLevel || DEFAULT_COMPRESSION }),
'jpg': () => sharp().jpeg({ quality: outputSettings.compressionLevel || DEFAULT_COMPRESSION }),
'png': () => sharp().png({ compressionLevel: outputSettings.compressionLevel | DEFAULT_PNG_COMPRESSION }),
'webp': () => sharp().webp({ quality: outputSettings.compressionLevel || DEFAULT_COMPRESSION })
'jpeg': () => sharp().jpeg({ quality: outputSettings.compressionLevel || DEFAULT_COMPRESSION, ...overrides }),
'jpg': () => sharp().jpeg({ quality: outputSettings.compressionLevel || DEFAULT_COMPRESSION, ...overrides }),
'png': () => sharp().png({ compressionLevel: outputSettings.compressionLevel || DEFAULT_PNG_COMPRESSION, ...overrides }),
'webp': () => sharp().webp({ quality: outputSettings.compressionLevel || DEFAULT_COMPRESSION, ...overrides })
}

@@ -109,3 +111,3 @@ data.getDiffImage().pack()

sharp(screenShot)
.jpeg({quality: outputSettings.compressionLevel || DEFAULT_COMPRESSION})
.jpeg({quality: outputSettings.compressionLevel || DEFAULT_COMPRESSION, ...overrides})
.toFile(newFilePath);

@@ -115,3 +117,3 @@ break;

sharp(screenShot)
.webp({quality: outputSettings.compressionLevel || DEFAULT_COMPRESSION})
.webp({quality: outputSettings.compressionLevel || DEFAULT_COMPRESSION, ...overrides})
.toFile(newFilePath);

@@ -121,3 +123,3 @@ break;

sharp(screenShot)
.png({quality: outputSettings.compressionLevel || DEFAULT_PNG_COMPRESSION})
.png({compressionLevel: outputSettings.compressionLevel || DEFAULT_PNG_COMPRESSION, ...overrides})
.toFile(newFilePath);

@@ -138,2 +140,3 @@ }

const storeExt = outputSettings.forceExt != null ? outputSettings.forceExt : ext.substring(ext.lastIndexOf(".")+1);
const overrides = outputSettings.overrides || {};
switch (storeExt) {

@@ -143,3 +146,3 @@ case 'jpeg':

await sharp(screenShot)
.jpeg({ quality: outputSettings.compressionLevel || DEFAULT_COMPRESSION })
.jpeg({ quality: outputSettings.compressionLevel || DEFAULT_COMPRESSION, ...overrides })
.toFile(`${saveFolder}/${name}${ext}`);

@@ -149,3 +152,3 @@ break;

await sharp(screenShot)
.webp({ quality: outputSettings.compressionLevel || DEFAULT_COMPRESSION })
.webp({ quality: outputSettings.compressionLevel || DEFAULT_COMPRESSION, ...overrides })
.toFile(`${saveFolder}/${name}${ext}`);

@@ -155,3 +158,3 @@ break;

await sharp(screenShot)
.png({ quality: outputSettings.compressionLevel || DEFAULT_PNG_COMPRESSION })
.png({ compressionLevel: outputSettings.compressionLevel || DEFAULT_PNG_COMPRESSION, ...overrides })
.toFile(`${saveFolder}/${name}${ext}`);

@@ -158,0 +161,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc