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

[no-large-snapshots] line count incorrect for inline snapshots #969

Closed
lexanth opened this issue Oct 27, 2021 · 1 comment · Fixed by #1005
Closed

[no-large-snapshots] line count incorrect for inline snapshots #969

lexanth opened this issue Oct 27, 2021 · 1 comment · Fixed by #1005

Comments

@lexanth
Copy link

lexanth commented Oct 27, 2021

no-large-snapshots counts the length of the snapshot based on the whole CallExpression from expect to the end. Therefore it includes the expect side in the limit, where the limit is described in the documentation (and at least I expected) as the limit of the snapshot itself.

e.g.

expect(
  functionUnderTest(
    arg1,
    arg2,
    arg3
  )
).toMatchInlineSnapshot(`
a
b
c`)

With a max size of 5, this should be fine - the snapshot is 4 lines long, including the initial empty line.

However, the rule measures from expect so gets 10 lines, so would fail.

IMO the rule should only measure the length of the actual snapshot template literal. I don't think this is technically a breaking change as no code which passed previously could fail now.

@G-Rath G-Rath changed the title no-large-snapshots incorrectly counts lines for inline snapshots [no-large-snapshots] no-large-snapshots incorrectly counts lines for inline snapshots Oct 28, 2021
@G-Rath G-Rath changed the title [no-large-snapshots] no-large-snapshots incorrectly counts lines for inline snapshots [no-large-snapshots] line count incorrect for inline snapshots Oct 28, 2021
@G-Rath G-Rath added the bug label Dec 26, 2021
@github-actions
Copy link

🎉 This issue has been resolved in version 25.3.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
Projects
None yet
2 participants