Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Snapshots excessively large or failing with Invalid string length #6645

Open
BrianValente opened this issue Oct 28, 2024 · 1 comment
Open
Labels
Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Platform: Web This issue is specific to web Repro provided A reproduction with a snippet of code, snack or repo is provided

Comments

@BrianValente
Copy link

Description

Since Reanimated v3.16.0, snapshots using @testing-library/react-native have been breaking. In some cases, the snapshot size has increased drastically, going from less than 1 KB to over 250 MB. In other cases, snapshots fail to generate, throwing an Invalid string length error.

v3.15.5

 PASS  ./ComponentTwo.test.tsx
 › 1 snapshot written.
 PASS  ./ComponentOne.test.tsx
 › 1 snapshot written.

Snapshot Summary
 › 2 snapshots written from 2 test suites.

Test Suites: 2 passed, 2 total
Tests:       2 passed, 2 total
Snapshots:   2 written, 2 total
Time:        1.938 s, estimated 22 s
➜ ls -lh
total 16
-rw-r--r--@ 1 brianvalente  staff   586B Oct 28 16:22 ComponentOne.test.tsx.snap
-rw-r--r--@ 1 brianvalente  staff   925B Oct 28 16:22 ComponentTwo.test.tsx.snap

v3.16.1

 PASS  ./ComponentOne.test.tsx (6.267 s)
 › 1 snapshot written.
 FAIL  ./ComponentTwo.test.tsx (9.18 s)
  ● ComponentTwo › should pass

    RangeError: Invalid string length

       6 |     it("should pass", () => {
       7 |         const rendered = render(<ComponentTwo />).toJSON();
    >  8 |         expect(rendered).toMatchSnapshot();
         |                          ^
       9 |     });
      10 | })
      11 |

      at printElement (node_modules/jest-snapshot/node_modules/pretty-format/build/plugins/lib/markup.js:105:36)
      at Object.toMatchSnapshot (ComponentTwo.test.tsx:8:26)

Snapshot Summary
 › 1 snapshot written from 1 test suite.

Test Suites: 1 failed, 1 passed, 2 total
Tests:       1 failed, 1 passed, 2 total
Snapshots:   1 written, 1 total
Time:        9.404 s
➜ ls -lh
total 537280
-rw-r--r--@ 1 brianvalente  staff   262M Oct 28 16:23 ComponentOne.test.tsx.snap

Steps to reproduce

  1. Clone demo repo
  2. Install dependencies
  3. Run npm run test

Snack or a link to a repository

https://github.com/BrianValente/reanimated-jest-snapshot-issue-demo

Reanimated version

3.6.1

React Native version

0.74.5

Platforms

Android, iOS, macOS, Web

JavaScript runtime

Hermes

Workflow

Expo Dev Client

Architecture

Paper (Old Architecture)

Build type

Other (please specify)

Device

None

Device model

No response

Acknowledgements

Yes

@github-actions github-actions bot added Repro provided A reproduction with a snippet of code, snack or repo is provided Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Platform: Web This issue is specific to web labels Oct 28, 2024
@arelstone
Copy link

arelstone commented Nov 5, 2024

I am facing the same issue. I am running RN 0.75.4

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Platform: Web This issue is specific to web Repro provided A reproduction with a snippet of code, snack or repo is provided
Projects
None yet
Development

No branches or pull requests

2 participants