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

toMatchFileSnapshot does not work #4177

Closed
6 tasks done
jacobbogers opened this issue Sep 25, 2023 · 1 comment
Closed
6 tasks done

toMatchFileSnapshot does not work #4177

jacobbogers opened this issue Sep 25, 2023 · 1 comment

Comments

@jacobbogers
Copy link

jacobbogers commented Sep 25, 2023

Describe the bug

If I use toMatchFileSnapshot the output of expect(document.body).toMatchFileSnapsot('./__snapshots__/test.snap is always

<body>
  <div />
</body>

If the exact same statement is replaced by expect(document.body).toMatchInlineSnapshot() , I see real content

Reproduction

No reproduction needed

System Info

- node: v20.1.0
- vitest@0.34.4
- vite: 4.4.9
- react-testinglibrary 
- @testing-library/dom: 8.13.0
- @testing-library/user-event: 14.5.1

Used Package Manager

npm

Validations

@jacobbogers
Copy link
Author

OK, I found out you need to make sure to:

  1. use the expect passed by as an argument to it('sometest', ({ expect }) => {...})
  2. make sure you only create one snapshot file per it test

@github-actions github-actions bot locked and limited conversation to collaborators Oct 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant