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: no-large-snapshots to allow maxSize of 0 #132
fix: no-large-snapshots to allow maxSize of 0 #132
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for sending a PR! I left a small inline comment, other than that LGTM
rules/no-large-snapshots.js
Outdated
(context.options[0] && context.options[0].maxSize) || 50; | ||
context.options[0] && | ||
typeof context.options[0].maxSize === 'number' && | ||
isFinite(context.options[0].maxSize) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we do Number.isFinite
? Then you can drop the typeof
check 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing!
@@ -22,7 +26,9 @@ module.exports = { | |||
if (lineCount > lineLimit) { | |||
context.report({ | |||
message: | |||
'Expected Jest snapshot to be smaller than {{ lineLimit }} lines but was {{ lineCount }} lines long', | |||
lineLimit === 0 | |||
? 'Expected to not encounter a Jest snapshot but was found with {{ lineCount }} lines long' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice one!
Signed-off-by: Paul Armstrong <parmstrong@twitter.com>
ef10b64
to
7e5e4e3
Compare
🎉 This PR is included in version 21.20.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Thanks @SimenB ! |
Problem: Configuring the rule
jest/no-large-snapshots
with[{ maxSize: 0 }]
sets the line limit to50
instead of0
.Solution: Treat
0
as a requirement for no snapshot.