Change:
I am trying to render a component using the preliminary shadow renderer support in TestUtils. A simple reproducible test case of my issue is this When I run this in my Jest test, I get: It looks like this error is thrown whenever the component being rendered has . I thought perhaps the context was required (although I haven't had any problems omitting it in my actual app), but even when using I get the same exception.
I think this is a known issue with shallow rendering. cc
thanks for the report. Context isn't meant to be supported with shallow rendering (i.e., we haven't tested it), but it looks like you may be able to work around this problem by passing an object as the second argument to : it looks like an additional argument was to the shallow rendering API in . What was the thinking here? Can we default this to an empty object?
Thanks, the workaround works great. And I see you posted a fix as well so looking forward to that.

Discussion:
var SyntheticEvent = require('SyntheticEvent'); var assign = require('Object.assign'); <ins> var emptyObject = require('emptyObject'); </ins> var findDOMNode = require('findDOMNode'); var topLevelTypes = EventConstants.topLevelTypes;

); ReactShallowRenderer.prototype.render = function(element, context) { <ins> if (!context) { context = emptyObject; } </ins> var transaction = ReactUpdates.ReactReconcileTransaction.getPooled(); this._render(element, transaction, context); ReactUpdates.ReactReconcileTransaction.release(transaction);

}); var shallowRenderer = ReactTestUtils.createRenderer(); <del> shallowRenderer.render(<SomeComponent />, {}); </del> <ins> shallowRenderer.render(<SomeComponent />); </ins> shallowRenderer.unmount(); expect(componentWillUnmount).toBeCalled();

}); var shallowRenderer = ReactTestUtils.createRenderer(); <del> shallowRenderer.render(<SomeComponent />, {}); </del> <ins> shallowRenderer.render(<SomeComponent />); </ins> var result = shallowRenderer.getRenderOutput();

}); var shallowRenderer = ReactTestUtils.createRenderer(); <del> shallowRenderer.render(<SomeComponent />, {}); </del> <ins> shallowRenderer.render(<SomeComponent />); </ins> var result = shallowRenderer.getRenderOutput(); expect(result.type).toBe('div'); expect(result.props.children).toEqual([

<span className="child2" /> ]); <del> shallowRenderer.render(<SomeComponent aNew="prop" />, {}); </del> <ins> shallowRenderer.render(<SomeComponent aNew="prop" />); </ins> var updatedResult = shallowRenderer.getRenderOutput(); expect(updatedResult.type).toBe('a');

expect(updatedResultCausedByClick.props.className).toBe('was-clicked'); }); <ins> it('can shallowly render components with contextTypes', function() { var SimpleComponent = React.createClass({ contextTypes: { name: React.PropTypes.string, }, render: function() { return <div />; }, }); var shallowRenderer = ReactTestUtils.createRenderer(); shallowRenderer.render(<SimpleComponent />); var result = shallowRenderer.getRenderOutput(); expect(result).toEqual(<div />); }); </ins> it('Test scryRenderedDOMComponentsWithClass with TextComponent', function() { var renderedComponent = ReactTestUtils.renderIntoDocument(<div>Hello <span>Jim</span></div>); var scryResults = ReactTestUtils.scryRenderedDOMComponentsWithClass(