Skip to content

Refs with react-test-renderer (TypeError: Cannot read property 'ownerDocument' of null) #9244

@aaronplanell

Description

@aaronplanell

Do you want to request a feature or report a bug?
A bug in snapshots.

What is the current behavior?
It seems that there is a problem with the snapshots when you use other libraries like antd. The snapshot launch:

TypeError: Cannot read property 'ownerDocument' of null

If I mock all the library, the snapshot is almost empty.

If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install and yarn test.
You can download this example of my Github account: https://github.com/aaronplanell/ant-design-issue_5428

$ git clone https://github.com/aaronplanell/ant-design-issue_5428
$ cd ant-design-issue_5428
$ npm install
$ npm test

In the README.md you will find, step by step, the full proccess.

Besides, I opened an issue to antd: ant-design/ant-design#5428 and @yesmeck said me that was a problem of Jest/react-test-renderer.

Then I opened an issue to jest: jestjs/jest#3195. This time @thymikee confirmed what @yesmeck said, it's a problem of react-test-renderer.

What is the expected behavior?
I expect that the snapshot have the full HTML code in JSON format. It has no sense that snapshots fail if a library that you use (and works!) use refs.

Please provide your exact configuration and mention your Jest, node, yarn/npm version and operating system.
I use this dependencies:

  "devDependencies": {
    "react-scripts": "0.9.5"
  },
  "dependencies": {
    "antd": "^2.8.2",
    "react": "^15.4.2",
    "react-dom": "^15.4.2",
    "react-test-renderer": "^15.4.2"
  },

With this OS: Ubuntu 16.04

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