Rangeerror: Invalid string length

See original GitHub issue

Trying to run Jest tests, but it’s failing with an error. I am trying to do snapshot testing but it fails with

 RangeError: Invalid string length

      at printObjectProperties (node_modules/pretty-format/build/collections.js:172:47)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:281:48)
      at printer (node_modules/pretty-format/build/index.js:364:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:171:21)

This is one of the test that keeps failing:

it('snapshot testing', () => {
    const demoItem = mountWithIntl(<DemoItem store={testStore} demoUnchange={jest.fn()} demoReply={demoReply} demoRef={jest.fn()} />);
    expect(toJson(demoItem)).toMatchSnapshot();
  });

My package.json has this Jest configuration:

"jest": {
    "verbose": true,
    "snapshotSerializers": [
      "enzyme-to-json/serializer"
    ]
  }
  • “enzyme”: “^3.9.0”
  • “enzyme-adapter-react-16”: “^1.10.0”
  • “enzyme-react-intl”: “^2.0.3”
  • “enzyme-redux”: “^0.2.1”
  • “enzyme-to-json”: “^3.3.5”
  • “babel-jest”: “^24.1.0”

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

10reactions
JossanPetrenkocommented, Sep 9, 2020

same problem on React Native 0.63

4reactions
StarryFirecommented, Sep 6, 2020

Hi, i am facing this error on React Native 0.63, any possible fixes for this? Can’t find any proper solutions online.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught RangeError: Invalid string length when appending ...
Your 2-D array accesses are incorrect, but the main problem is that you're re-using the variable i in an inner loop: for (i...
Read more >
RangeError: Invalid string length with large files. · Issue #35973
When i'm trying to read a large Json File (700MB - 26.640.222 lines) using ReadStream i'm getting the error: "RangeError: Invalid string length" ......
Read more >
RangeError: invalid array length - JavaScript - MDN Web Docs
The JavaScript exception "Invalid array length" occurs when specifying an array length that is either negative, a floating number or exceeds ...
Read more >
Simplest solution to JSON.stringify RangeError: Invalid string ...
stringify RangeError: Invalid string length. We often come across this issue where the object or value passed to JSON.
Read more >
HTML : Uncaught RangeError: Invalid string length ... - YouTube
HTML : Uncaught RangeError : Invalid string length when appending to a string in JavaScript [ Beautify Your Computer ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found