These are chat archives for airbnb/enzyme

21st
Jun 2017
Sean Matheson
@ctrlplusb
Jun 21 2017 10:06

Hey all I am trying to assert against an element that is provided as a prop to a component.
e.g.

function ComponentUnderTest() {
   const foo = <span>👋</span>
   return <Bob something={foo} />
}

I have tried doing something like:

shallow(<ComponentUnderTest />)
  .prop(‘something’)
  .matchesElement(<span>👋</span>)

But I just get (0 , _enzyme.shallow)(...).prop(...).matchesElement is not a function
Any ideas?

Sean Matheson
@ctrlplusb
Jun 21 2017 10:15
It’s like I need to lift the something prop value into the enzyme wrapper API
Jordan Harband
@ljharb
Jun 21 2017 16:05
@ctrlplusb there's no easy way to do that. you'd have to wrap the prop value in a div and shallow render it first.
Sean Matheson
@ctrlplusb
Jun 21 2017 16:11
@ljharb thanks for tip 👍