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

Add a rules to help with the .toMatchNamedSnapshot() matcher usage #1367

Closed
mrazauskas opened this issue Apr 20, 2023 · 3 comments
Closed

Add a rules to help with the .toMatchNamedSnapshot() matcher usage #1367

mrazauskas opened this issue Apr 20, 2023 · 3 comments
Labels

Comments

@mrazauskas
Copy link
Contributor

From jestjs/jest#14045 (comment)

The linked PR is about to add .toMatchNamedSnapshot() matcher to Jest. The matcher works similar to .toMatchSnapshot(), but requires setting snapshot name explicitly that allows snapshot testing in concurrent mode (details of the problem jestjs/jest#2180).

After the PR lands, eslint-plugin-jest could be helpful by adding these rules:

  • no-duplicate-snapshot-names: show error if the same snapshot name was used twice in a test file
  • prefer-named-snapshots: require to use .toMatchNamedSnapshot() matcher with test.concurrent (or always)

This is just a note for discussion. No action required at the moment (;

@SimenB
Copy link
Member

SimenB commented Apr 21, 2023

I think both of these rules sounds good. @G-Rath thoughts?

@G-Rath
Copy link
Collaborator

G-Rath commented Apr 22, 2023

Yeah they sound reasonable (though I'd probably say go with prefer-snapshot-name to match nicely with prefer-snapshot-hint) - you could do prefer-snapshot-name with no-restricted-matchers, though that would be all or nothing and I guess it makes sense for us to tell people by default what to do when using concurrent

@mrazauskas
Copy link
Contributor Author

The concurrent snapshots are now supported without adding new matcher (see jestjs/jest#14139). So the rules will not be needed.

@jest-community jest-community deleted a comment Jul 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants