mzgoddard / preact-render-spy

Render preact components with access to the produced virtual dom for testing.

Home Page:https://www.npmjs.com/package/preact-render-spy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: Cannot read property 'nodeName' of null

mparpaillon opened this issue · comments

Hi,
Thanks for this. It looks cool.

I get this TypeError: Cannot read property 'nodeName' of null error though. I haven't looked at all the code yet but it looks like you're recursively checking the vdom and at some point you try to check the nodeName of null

I think we should add a test on vdom being null here: https://github.com/mzgoddard/preact-render-spy/blob/master/src/preact-render-spy.js#L10

It seems to work when I add this at the beginning of spyWalk:

if (vdom === null) {
  return '';
}

Does it make sense ?

No, I just don't think we had a test case for <div>{[ null, <div /> ]}</div> type scenario yet.

I'll add a test case real quick

#11 should fix the problem, just waiting for the travis to pass!

Thanks for catching this one!

Let us know if there are other test cases that fail (feel free to write a failing test case for us! 😄 )

Have you npm publish the package ? Or should I install from the github url ?

It's OK, I've installed it from github. Works fine :)

@mparpaillon I published the fix in v0.0.2

Heads up @mparpaillon - we are getting pretty close to what we would feel comfortable calling a 1.0.0 -- Do you have any more feedback for us / can you take a look at the README on master / the open PR's and help us sanity check for your use cases?