pzavolinsky / react-unit

Lightweight unit test library for ReactJS
MIT License
194 stars 15 forks source link

findByComponent and proxyquire #27

Open ghost opened 7 years ago

ghost commented 7 years ago

Hi there, There seems to be an issues whereby when you instantiate a react component via proxiquireify and perform a findByComponent on a subcomponent that react-unit us unable to find it even when a .dump() returns the item to be found.

e.g. If was was proxyquiring a Header component and within it, there was a Logo component. Without proxying it, the findByComponent will return the Logo component but as soon as you proxyquirify the

component, it can never be found. Any ideas about an easy repeatable way to achieve this?

Reference proxiquirify

pzavolinsky commented 7 years ago

Hi @russellholmes thanks for reporting this.

I'm not familiar with proxiquirify, can you send me a reduced version of the test that is giving problems? Maybe that Header / Logo example?

Does this work: header.findByQuery('Logo')?

findByComponent compares component definitions by reference so maybe proxiquirify is returning something that looks like Logo but is not the original Logo (this is just a guess, not sure what is actually happening).

Also not sure if this fits your scenario but maybe you could try using .mock() or .exclude().

Cheers!