Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dumpDiffToConsole base64 string output #183

Merged
merged 3 commits into from
Mar 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion __tests__/diff-snapshot.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ describe('diff-snapshot', () => {
pass: false,
});

const isBase64ImgStr = result.imgSrcString.includes('data:image') && result.imgSrcString.includes('base64');
const isBase64ImgStr = result.imgSrcString.includes('data:image/png;base64,iV');
expect(isBase64ImgStr).toBe(true);

expect(mockPixelMatch).toHaveBeenCalledTimes(1);
Expand Down
2 changes: 1 addition & 1 deletion src/diff-snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ function diffImageToSnapshot(options) {
diffOutputPath,
diffRatio,
diffPixelCount,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add an integration test for this?

Copy link
Contributor Author

@bstst bstst Mar 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An existing spec was actually doing this incorrectly (or rather incompletely), so I fixed it.

imgSrcString: `data:image/png;base64,${pngBuffer}`,
imgSrcString: `data:image/png;base64,${pngBuffer.toString('base64')}`,
};
} else if (shouldUpdate({ pass, updateSnapshot, updatePassedSnapshot })) {
mkdirp.sync(snapshotsDir);
Expand Down