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.
@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.
@JedWatson I've opened a PR for this. https://github.com/JedWatson/react-select/pull/107
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.
@JedWatson Excellent. Glad I could help!
i am getting the Maximum call stack size exceeded in react-native. please provide the solution .
Thanks in advance
Nishant Singh
Most helpful comment
i am getting the Maximum call stack size exceeded in react-native. please provide the solution .
Thanks in advance
Nishant Singh