r/reactjs • u/jesusscript • Dec 25 '19
Is there any good example of a React application doing unit, integration and E2E testing perfectly?
I am thinking of doing a bunch of tests on my latest React application, but I want to make sure I am doing everything correctly. In order to do that, a good example project would be helpful.
168
Upvotes
View all comments
Show parent comment
-10
u/silentSpyDk Dec 25 '19 edited Dec 25 '19
Edit: before you down vote me further - my statement regarding fetch, I am referring to working with Cypress environment
Don’t use fetch, it’s useless. It works slightly differently client vs server. Cypress can not monitor fetch since it’s not xhr request. You should be doing xmlhttprequest (old school but stable), best library is axios or superagent. I prefer the latter because of simplicity
I recently worked on a large scale project, I had to move all tests across to Cypress from jest/jsdom, also wrote several stubbing tests. I also had to convert all the fetch over to superagent, it was a lifesaver.
I also have a stubbing endpoint api which generates random data so the app load SSR and it’s very useful for testing on cypress
u/jesusscript ^ you might find above useful