News for hackers. Stuff that matters.
Re:React v18.0 by acdlite on Tuesday March 29, 2022 @01:37PM (#30845839)
Not sure what Enzyme's plans are, since I know they depend on some React internals.

However, we've worked closely with the React Testing Library maintainers, and that's the solution I'd recommend for React tests going forward. We're fans of RTL because it encourages you to write tests "end-2-end"-like tests that resemble real-world scenarios and are resilient to implementation changes.

Re:React v18.0 by RussianCow on Tuesday March 29, 2022 @03:21PM (#30847167)
That's a shame, because there are plenty of use cases where testing a shallow render makes much more sense than fully rendering the component—for example, when you're wrapping a third-party library and simply need to test that the correct props are being passed, instead of testing the library's functionality.
Re:React v18.0 by danabramov on Tuesday March 29, 2022 @04:02PM (#30847637)
Usually you can do this by mocking that specific library out at the module level. E.g. Jest has functionality for this.
Re:React v18.0 by RussianCow on Wednesday March 30, 2022 @01:39AM (#30851811)
Sure, but using Enzyme has been easier and far less brittle in my experience by being less reliant on hacky, library-specific mocking techniques. (Then again, I suppose you could argue that Enzyme is itself a giant hack, but it worked very well for me in the past.)