Skip to content

Change in _owner causes issues with shallow rendered tests #5292

@hatched

Description

@hatched

There appears to have been a change in how _owner is generated between 0.13 and 0.14 which is causing a number of our shallow rendered tests to fail when upgrading because the deepEquals fails on the _owner property. Here is a simple example component which exhibits the issue.

'use strict';

fdescribe('ComponentTest', function() {

  it('passes in 0.13 but fails in 0.14', function() {
    var components = {};
    components.tester = React.createClass({

      getInitialState: function() {
        return this.generateState();
      },

      generateState: function() {
        var state = {};
        state.body = (
          <ul className="foo">
            <li><div>Item 1</div></li>
            <li>Item 2</li>
          </ul>);
        return state;
      },

      render: function() {
        return (
          <div className="foo">
            {this.state.body}
          </div>);
      }
    });

    var shallowRenderer = testUtils.createRenderer();
    shallowRenderer.render(<components.tester />);
    var output = shallowRenderer.getRenderOutput();

    assert.deepEqual(output,
      <div className="foo">
        <ul className="foo">
          <li><div>Item 1</div></li>
          <li>Item 2</li>
        </ul>
      </div>);
  });
});
    AssertionError: expected { '$typeof': 60103,
      type: 'div',
      key: null,
      ref: null,
      props: 
       { className: 'foo',
         children: 
          { '$typeof': 60103,
            type: 'ul',
            key: null,
            ref: null,
            props: [Object],
            _owner: [Object],
            _store: {} } },
      _owner: null,
      _store: {} } to deeply equal { '$typeof': 60103,
      type: 'div',
      key: null,
      ref: null,
      props: 
       { className: 'foo',
         children: 
          { '$typeof': 60103,
            type: 'ul',
            key: null,
            ref: null,
            props: [Object],
            _owner: null,
            _store: {} } },
      _owner: null,
      _store: {} }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions