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

jest/no-large-snapshots doesn't work on external snap files #1353

Closed
westthomas-dev opened this issue Mar 15, 2023 · 2 comments · Fixed by #1373
Closed

jest/no-large-snapshots doesn't work on external snap files #1353

westthomas-dev opened this issue Mar 15, 2023 · 2 comments · Fixed by #1373
Labels

Comments

@westthomas-dev
Copy link

After configuring the jest/no-large snapshots rule, errors are only being raised for inline snapshots, not for external snapshot files.

Rule configuration:

"jest/no-large-snapshots": ["error", { "maxSize": 10, "inlineMaxSize": 10 }]

I have tried creating a new react app with typescript via CRA and configuring this rule in a clean application. It is detecting inline snapshot violations of the rule but no error is raised for separate .snap files.

I have followed the documentation adding the relevant plugins and set the ecmaVersion to latest.

The example uses the out of the box App.test.tsx / App.test.tsx.snap.

Snapshot test - App.test.tsx

test('matches snapshot', () => {
  const {container} = render(<App/>);
  expect(container).toMatchSnapshot();
})

Snapshot file contents - App.test.tsx.snap

// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`matches snapshot 1`] = `
<div>
  <div
    class="App"
  >
    <header
      class="App-header"
    >
      <img
        alt="logo"
        class="App-logo"
        src="logo.svg"
      />
      <p>
        Edit 
        <code>
          src/App.tsx
        </code>
         and save to reload.
      </p>
      <a
        class="App-link"
        href="https://reactjs.org"
        rel="noopener noreferrer"
        target="_blank"
      >
        Learn React
      </a>
    </header>
  </div>
</div>
`;

Any advice or support would be appreciated.

@G-Rath
Copy link
Collaborator

G-Rath commented Mar 15, 2023

Would you mind putting together a small self-contained repo reproducing the issue?

@github-actions
Copy link

🎉 This issue has been resolved in version 27.2.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 a pull request may close this issue.

2 participants