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

test: Fix inline snapshot mismatch on certain machines #1040

Merged
merged 4 commits into from
Sep 30, 2021

Conversation

bpinto
Copy link
Contributor

@bpinto bpinto commented Sep 29, 2021

What:

Two snapshot tests were failing locally while passing on CI, this change fixes it so that tests are green on CI as well as locally.

The replaced library was appending extra double quotes at the begging and end of the string.

https://github.com/joaogranado/jest-serializer-ansi/blob/c8c5e8cbc0f804f9fe195dfd27625ea0b3d2a062/index.js#L13-L16

How:

Replacing jest-serializer-ansi library with jest-snapshot-serializer-ansi.

Checklist:

  • Documentation added to the docs site N/A
  • Tests
  • TypeScript definitions updated N/A
  • Ready to be merged

@@ -45,16 +45,34 @@ test('prettyDOM defaults to document.body', () => {
</body>"
`
renderIntoDocument('<div>Hello World!</div>')
expect(prettyDOM()).toMatchInlineSnapshot(defaultInlineSnapshot)
expect(prettyDOM(null)).toMatchInlineSnapshot(defaultInlineSnapshot)
expect(prettyDOM()).toMatchInlineSnapshot(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm... not sure what happened here, I need to investigate this change.

Copy link
Contributor Author

@bpinto bpinto Sep 29, 2021

Choose a reason for hiding this comment

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

Okay, fixed, it was a problem with automatically updating inline snapshots.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Sep 29, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 3723cbe:

Sandbox Source
react-testing-library-examples Configuration

@codecov
Copy link

codecov bot commented Sep 29, 2021

Codecov Report

Merging #1040 (3723cbe) into main (8746d21) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##              main     #1040   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           25        25           
  Lines          920       920           
  Branches       284       284           
=========================================
  Hits           920       920           
Flag Coverage Δ
node-12 100.00% <ø> (ø)
node-14 100.00% <ø> (ø)
node-16.9.1 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8746d21...3723cbe. Read the comment docs.

@eps1lon
Copy link
Member

eps1lon commented Sep 29, 2021

That's awesome! Will check tomorrow if this fixes it for me locally. And then we probably want to apply this fix in all testing-library repos

@bpinto
Copy link
Contributor Author

bpinto commented Sep 29, 2021

Let me know how it goes! Regarding other testing-library repos, I could not find any other repository making use of ansi snapshot tests, I found this PR removing some snapshot tests on jest-dom repository, maybe this was experiencing a similar issue?

@timdeschryver
Copy link
Member

If you need someone on a Windows environment to test this, feel free to ping me.

@bpinto
Copy link
Contributor Author

bpinto commented Sep 29, 2021

@timdeschryver sorry if the comment wasn't for me, but if I may, I think running tests on Windows could do no harm and would, in fact, add more confidence to these changes. So please, if you could test on Windows, I think that would be great.

Copy link
Member

@timdeschryver timdeschryver left a comment

Choose a reason for hiding this comment

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

Works on my machine 👍

@eps1lon eps1lon changed the title Fix broken specs test: Fix inline snapshot mismatch on certain machines Sep 30, 2021
Copy link
Member

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

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

Awesome!

@eps1lon eps1lon merged commit f27d14c into testing-library:main Sep 30, 2021
@bpinto bpinto deleted the fix-broken-specs branch September 30, 2021 13:33
@github-actions
Copy link

github-actions bot commented Oct 4, 2021

🎉 This PR is included in version 8.7.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants