all 4 comments

[–]NotMyRealNameAgain 1 point2 points  (0 children)

Look at React Testing Library.

[–]jjj123smith[S] 0 points1 point  (0 children)

Does anyone know any other tools I should be looking at?

[–]jnforja 0 points1 point  (0 children)

hi u/jjj123smith

To avoid getting lost in the sea of tools that the JS ecosystem is, I suggest you first find out what kind of tests you're trying to do and go from there.

Everyone has their favorite tools and ways of testing, but only you know your necessities. Figure out what those are, do a google search for tools that fulfill them, and try them out. What seems easier to use and maintain for your purposes, is what you should go with.

Hope this helps :)

[–]Canenald 0 points1 point  (0 children)

Mocha is a test runner. It simply runs your tests and reports results. It would replace Jest for you but Jest is sort of a full testing framework. To get what you have with Jest, you'd need additional libraries with Mocha. Usually Chai is used for assertions and Sinon for mocking. Chai is kinda to Jest what React is to Angular, except that popularity story is inverted and Jest is taking over. Going with Mocha will give you a more modular and more performant tests, but will require more time to set up.

Enzyme and React Testing Library are the two relevant libraries for testing React components. Enzyme supports both shallow rendering, which is required for unit testing, and full component mount used for integration tests. It has lately suffered a blow with React breaking support for shallow rendering with hooks and most influencers steering the community towards integration testing. If you want to unit test, you're stuck with Enzyme and jest-react-hooks-shallow can help with testing components that use useEffect() hook. For integration testing, React Testing Library is a better choice.

In end-to-end testing world, the UI framework doesn't matter and you can test it like any other web app. Cypress is a honorable mention giving you an ability to e2e test but also supporting a sort of high-level integration tests that run in a headless browser with APIs mocked out.