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

jest-image-snapshot

Package Overview
Dependencies
Maintainers
5
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-image-snapshot - npm Package Compare versions

Comparing version 2.8.0 to 2.8.1

61

__tests__/integration.spec.js

@@ -19,3 +19,3 @@ /*

const uniqueId = require('lodash/uniqueId');
const isPng = require('is-png');
const sizeOf = require('image-size');
const { SnapshotState } = require('jest-snapshot');

@@ -231,7 +231,62 @@ const { toMatchImageSnapshot } = require('../src');

const imageBuffer = fs.readFileSync(pathToResultImage);
// just because file was written does not mean it is a png image
expect(isPng(imageBuffer)).toBe(true);
expect(sizeOf(pathToResultImage)).toHaveProperty('type', 'png');
});
it('writes a result image for failing tests with horizontal layout', () => {
const customSnapshotIdentifier = getIdentifierIndicatingCleanupIsRequired();
const pathToResultImage = path.join(__dirname, diffOutputDir(), `${customSnapshotIdentifier}-diff.png`);
// First we need to write a new snapshot image
expect(
() => expect(imageData).toMatchImageSnapshot({
customSnapshotIdentifier,
diffDirection: 'horizontal',
})
).not.toThrowError();
// then test against a different image
expect(
() => expect(failImageData).toMatchImageSnapshot({
customSnapshotIdentifier,
diffDirection: 'horizontal',
})
).toThrow();
expect(fs.existsSync(pathToResultImage)).toBe(true);
expect(sizeOf(pathToResultImage)).toMatchObject({
width: 300,
height: 100,
type: 'png',
});
});
it('writes a result image for failing tests with vertical layout', () => {
const customSnapshotIdentifier = getIdentifierIndicatingCleanupIsRequired();
const pathToResultImage = path.join(__dirname, diffOutputDir(), `${customSnapshotIdentifier}-diff.png`);
// First we need to write a new snapshot image
expect(
() => expect(imageData).toMatchImageSnapshot({
customSnapshotIdentifier,
diffDirection: 'vertical',
})
).not.toThrowError();
// then test against a different image
expect(
() => expect(failImageData).toMatchImageSnapshot({
customSnapshotIdentifier,
diffDirection: 'vertical',
})
).toThrow();
expect(fs.existsSync(pathToResultImage)).toBe(true);
expect(sizeOf(pathToResultImage)).toMatchObject({
width: 100,
height: 300,
type: 'png',
});
});
it('removes result image from previous test runs for the same snapshot', () => {

@@ -238,0 +293,0 @@ const customSnapshotIdentifier = getIdentifierIndicatingCleanupIsRequired();

8

package.json
{
"name": "jest-image-snapshot",
"version": "2.8.0",
"version": "2.8.1",
"description": "Jest matcher for image comparisons. Most commonly used for visual regression testing.",

@@ -48,4 +48,4 @@ "main": "src/index.js",

"eslint-config-amex": "^7.0.0",
"is-png": "^1.1.0",
"jest": "^23.0.0",
"image-size": "^0.7.1",
"jest": "^24.0.0",
"mock-spawn": "^0.2.6",

@@ -64,4 +64,4 @@ "jest-snapshot": "^23.0.0"

"peerDependencies": {
"jest": ">=20 <=23"
"jest": ">=20 <=24"
}
}

@@ -14,3 +14,3 @@ # jest-image-snapshot

Please note that `Jest` `>=20 <=23` is a peerDependency. `jest-image-snapshot` will **not** work with anything below Jest 20.x.x
Please note that `Jest` `>=20 <=24` is a peerDependency. `jest-image-snapshot` will **not** work with anything below Jest 20.x.x

@@ -17,0 +17,0 @@ ## Usage:

@@ -174,3 +174,3 @@ /*

const composer = new ImageComposer({
diffDirection,
direction: diffDirection,
});

@@ -177,0 +177,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