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

Testing - RangeError: Maximum call stack size exceeded #86

Closed
mattdell opened this issue Mar 9, 2015 · 5 comments
Closed

Testing - RangeError: Maximum call stack size exceeded #86

mattdell opened this issue Mar 9, 2015 · 5 comments

Comments

@mattdell
Copy link
Contributor

mattdell commented Mar 9, 2015

I'm using the react-select component in my application and whenever it is referenced in my Jest tests I get an error that says "RangeError: Maximum call stack size exceeded".

Here is a basic test I've written using Jest based on the react-select example.

/** @jsx React.DOM */
'use strict';
jest.autoMockOff();

var React = require("react/addons");
var Select = require("react-select");
var TestUtils = React.addons.TestUtils;

describe("Select test", function() {

    var Select = require('react-select');

    var options = [
        { value: 'one', label: 'One' },
        { value: 'two', label: 'Two' }
    ];

    function logChange(val) {
        console.log("Selected: " + val);
    }

    // Render an instance of the component
    var instance = TestUtils.renderIntoDocument(
        <Select
            name="form-field-name"
            value="one"
            options={options}
            onChange={logChange}/>
        );
});

By simplifying the test to this level, I can assume the range error is happening within react-select. I also see Issue #73 there are no tests for react-select.

Does anyone else have a similar issue? I'm quite surprised the basic example implementation of the component won't pass a simple unit test.

@JedWatson
Copy link
Owner

@mattdell I'm quite surprised too. It sounds like the test is firing off some kind of infinite loop (that's usually what leads to RangeErrors) - maybe it's something to do with the mock interfaces? ...because it doesn't seem to happen in the browser. I'm not familiar with using jest or React.TestUtils (both things I've been meaning to get to).

As I just mentioned in #73 any help getting tests in place for React-Select would be greatly appreciated.

@mattdell
Copy link
Contributor Author

@JedWatson I've opened a PR for this. #107

@JedWatson
Copy link
Owner

Thanks for your help with this @mattdell. I've tracked down the issue in the autosize-input component that was causing the infinite loop - it had to do with the logic that detects the width of the sizer element (which is mocked by Jest but not actually available).

Having fixed that, bumped all the versions and built a new release the tests now work as expected, so you should be able to test successfully in your own project now too.

@mattdell
Copy link
Contributor Author

@JedWatson Excellent. Glad I could help!

@ignivanishant
Copy link

i am getting the Maximum call stack size exceeded in react-native. please provide the solution .

Thanks in advance
Nishant Singh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants