Skip to content

Commit

Permalink
chore(test): convert error snapshot to regex to avoid env-specific is…
Browse files Browse the repository at this point in the history
…sues
  • Loading branch information
sbekrin committed Jan 22, 2018
1 parent 4c0502a commit 1410859
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
5 changes: 0 additions & 5 deletions __tests__/__snapshots__/integration.spec.js.snap
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`toMatchImageSnapshot failures fails gracefully with a differently sized image 3`] = `"toMatchImageSnapshot(): Received image size must match baseline snapshot size with \`outputDiffOnSizeMismatch\` set to \`false\`."`;

exports[`toMatchImageSnapshot failures writes diff for images with different sizes with outputDiffOnSizeMismatch set to true 3`] = `
"Expected image to match or be a close match to snapshot but was 83.55194951543837% different from snapshot (18536 differing pixels).
See diff for details: /Users/sbekrin/Projects/jest-image-snapshot/__tests__/__image_snapshots__/__diff_output__/cleanup-required-6-diff.png"
`;
3 changes: 2 additions & 1 deletion __tests__/integration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ describe('toMatchImageSnapshot', () => {
});

it('writes diff for images with different sizes with outputDiffOnSizeMismatch set to true', () => {
const expectedError = /Expected image to match or be a close match to snapshot but was 83\.55194951543837% different from snapshot \(18536 differing pixels\)\./;
const customSnapshotIdentifier = getIdentifierIndicatingCleanupIsRequired();
const outputDiffOnSizeMismatch = true;

Expand All @@ -161,7 +162,7 @@ describe('toMatchImageSnapshot', () => {
outputDiffOnSizeMismatch,
customSnapshotIdentifier,
})
).toThrowErrorMatchingSnapshot();
).toThrowError(expectedError);
});
});
});

0 comments on commit 1410859

Please sign in to comment.