developit / preact-jsx-chai

:white_check_mark: Add JSX assertions to Chai, with support for Preact Components.
http://npm.im/preact-jsx-chai
MIT License
56 stars 7 forks source link

Assertion fails when evaluating null next to sibling vnode #46

Closed aotarola closed 7 years ago

aotarola commented 7 years ago

Just found an issue when trying to upgrade to preact 8.1.0 on my component tests, it looks like when there is a null/false evaluation with a valid sibling vnode, the deep.equal assertion fails. I can explain better with an example, the test code is:

it('be triggered when JSX has null evaluation next to a valid sibling node', ()  => {
    expect(<jsx><span/>{null}</jsx>).to.deep.equal(<jsx><span/></jsx>);
});

and the result output is

  1) preact-jsx-chai assertJsx() sanity be triggered when JSX has null evaluation next to a valid sibling node:

      AssertionError: expected '<jsx>\n  <span></span>\n  \n</jsx>' to equal '<jsx>\n  <span></span>\n</jsx>'
      + expected - actual

       <jsx>
         <span></span>
      -
       </jsx>

I also have a custom branch to test this out.

Is this a known issue? is there any workaround this problem?

I will keep digging into this, I will update this issue for any findings.

Thanks!

developit commented 7 years ago

Fixed in preact-render-to-string 3.6.2. npm update to get it!