software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
9.09k stars 1.32k forks source link

Snapshots excessively large or failing with `Invalid string length` #6645

Open BrianValente opened 3 weeks ago

BrianValente commented 3 weeks ago

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

arelstone commented 2 weeks ago

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

t33n4gemutant commented 2 weeks ago

Also experiencing this

nicolas-meilan commented 2 weeks ago

I have the same issue

arelstone commented 2 weeks ago

My issue were caused by a regular useRef on an Animated.Scrollview. When it was changed to an useAnimatedRef the size went back to normal

MBauhoffer commented 2 weeks ago

Same here :(

mostfinance-ca commented 1 week ago

I am facing the same issue. I am running RN 0.76.1 and RNR 3.16.1

wkoutre commented 2 days ago

Also blocked by this

ally-bryand commented 1 day ago

I'm having the same issues with RN 0.76 and RNR 3.16.2

rotoxl commented 11 hours ago

+1, also blocked here