jest-image-snapshot
Advanced tools
Comparing version 2.8.0 to 2.8.1
@@ -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(); |
{ | ||
"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 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3162821
1812