enzyme: Cannot convert undefined or null to object.

Hi. I am using Jest with Enzyme. I have a component wrapped by few components(Provider, Intl, Relay). When i try to render the component with render function and then call .toMatchSnapshot it works perfect. But when i call mount instead of render it fails. The stack trace is:

TypeError: Cannot convert undefined or null to object
  
  at Object.<anonymous> (__tests__/common/Header/Header2.test.js:54:76)
  at handle (../node_modules/worker-farm/lib/child/index.js:41:8)
  at process.<anonymous> (../node_modules/worker-farm/lib/child/index.js:47:3)
  at emitTwo (../events.js:87:13)
  at process.emit (../events.js:172:7)
  at handleMessage (../internal/child_process.js:686:10)
  at Pipe.channel.onread (../internal/child_process.js:440:11)

The reason why i am calling mount that i need set props to the component. Perhaps the problem is not in enzyme but in worker-farm lib. Anyway any help will be appreciated.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 16 (7 by maintainers)

Most upvoted comments

The error message is:

    TypeError: Cannot convert undefined or null to object
      
      at Object.<anonymous> (__tests__/container/list/AccountsList.test.js:105:89)
      at process._tickCallback (internal/process/next_tick.js:103:7)

BTW, I will file another issue to enzyme-to-json and link both of them.

Hi! I have the same problem