FormidableLabs / react-fast-compare

fastest deep equal comparison for React
MIT License
1.59k stars 54 forks source link

Add test for Preact support #75

Closed kale-stew closed 4 years ago

kale-stew commented 4 years ago

Description

This PR introduces tests to the Preact support that was introduced in #67.

We still need to figure out how to pass props directly to the updated Preact component being updated here to verify the container's update fn is invoked (test case no. 3)

Checklist:

Bundle size is not impacted by tests

kale-stew commented 4 years ago

Ok, replied to the above feedback and got the tests synced up with each other, but now we're seeing legitimate failures for actual test conditions.

Case 1 - compares without warning or errors: expected 0, got 1 Case 2 - elements of same type and props are equal: expected 1, got 2

Edit: It looks like our Preact check isn't passing the Preact elements we've created in these tests whatsoever, which is why it's always re-rendering. Going to evaluate the Preact elements themselves, I assume I've duplicated React behavior that is incompatible with PreactChild and PreactContainer.

Edit, part 2: The offending check is a.$$typeOf which only returns React element data, it's coming back as undefined for everything Preact. Going to tie it to the React validator for now, until I can get more feedback from more Preact-smart folks 👍

kale-stew commented 4 years ago

Our tests are now failing because @testing-library/dom is incompatible with the node v8 engine that AppVeyor runs first. 😞

The library only just recently patch released support for Node v10 (one whole version newer) 13 days ago and has stated they plan to deprecate support whenever it's officially EOL (sometime mid-2021). This will be an issue for our current CI approach.

Can we skip specific tests for a specific Node version? Should we go about these tests a different way entirely? What % of users are using preact and node v<10?

ryan-roemer commented 4 years ago

@kale-stew -- I've added two small changes:

  1. 11a60b4 - Our coverage wasn't being generated in Node.js.
  2. d7f3b6f - Transpile a specific preact library. You can use this technique for other deps if we find them (if this isn't enough for ie11)
ryan-roemer commented 4 years ago

Updated cov to codecov (removed coveralls) with badge!

Also note, we're not running travis, but should pass because this branch doesn't target master. Will catch up in preact-support branch.