Skip to content

Why are react-dom error messages so cryptic?Β #10108

@binarykitchen

Description

@binarykitchen

When react-dom v15.5.4 throws an error during jest tests using test-utils, error messages can be so cryptic. Makes it harder for us developers to understand the problem. For example this one:

    TypeError: Cannot read property '__reactInternalInstance$snz0ajvq2ztcsor' of undefined

      at getClosestInstanceFromNode (node_modules/react-dom/lib/ReactDOMComponentTree.js:113:11)
      at Object.getInstanceFromNode (node_modules/react-dom/lib/ReactDOMComponentTree.js:147:14)
      at Object.change (node_modules/react-dom/lib/ReactTestUtils.js:336:74)
      at Object.<anonymous> (src/modules/views/form/__jest__/CancelSubmitButtons.es:34:34)
      at process._tickCallback (node.js:369:9)

Can't you put something more "readable" in __reactInternalInstance$snz0ajvq2ztcsor instead? Like what it's parent node is, what its tag name is etc. Would be extremely useful.

Using this test code btw:

  it('onCancel is fired', (done) => {
    const component = TestUtils.renderIntoDocument(
      <CancelSubmitButton
        disableCancel={false}
        onCancel={e => {
          expect(e.target.innerHTML).toEqual('Cancel')
          done()
        }}
      />
    )

    TestUtils.Simulate.click(component.refs.cancel, {target: {innerHTML: 'Cancel'}})
  })

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions