Testing in react

Hey everyone, I’ve been pondering whether diving into learning how to test React code is worth it. Does anyone here test their React code, and if so, how crucial do you find it? Appreciate any insights or experiences you can share!
E
Ehh16d ago
I don’t write any automated tests for front end code. What I do is use typescript to catch potential errors during development, test features manually after deploying in a dev environment and finally have Sentry running to catch bugs in prod Not recommended maybe, but that’s my approach. The few times I did spend time on writing tests they quickly became obsolete because requirements/features changed. In a fast moving environment these changes happen constantly. Perhaps in a more methodic and slow moving environment it makes more sense to write tests for your features.
R
raphico16d ago
Oh! Thanks for your feedback. I pretty much do the same: I use Typescript and Eslint to catch potential errors in development and manually test if everything works as it should in the development environment. What I haven't used is Sentry. I'll check it out. Again thanks for your feedback! 👍
M
michaeldrotar15d ago
I think the problem with FE testing is that so many people do them wrong so there's a perception that they waste time. But if you go to a company and start proclaiming that tests are bad, you may meet a lot of resistance. So learning how to test is important in that regard. I also, sadly, see a lot of companies leaning on code coverage as a measure of good testing when it actually encourages bad tests, but it's a pretty number to show in reports and measure each quarter. For instance, I see alot of people unit testing their components and hooks. But these things by their nature have side effects and so E2E tests are much better. But E2E tests are slower. So they fill their unit tests with mocks and implementation details for the sake of something running fast and giving a high code coverage number at the end. The tests only fail when changes are made.. even good changes.. and they never catch actual issues because they're mocked with things that work. I've seen Theo share similar thoughts but it is difficult to find content on how to write good tests cause there's so much nuance involved. I think it's more important to have something alerting to errors and having a process that allows you to get the fix to prod in minutes, not days. Then write tests afterwards in order to prevent regressions because now you have a clear example of something actually breaking and how it broke.. and also because there's nothing worse than a product manager getting mad that the team is fixing the same gosh darn problem for the 3rd month in a row.
C
cje15d ago
in a codebase of a couple hundred components, we test maybe like 5 of them. vast majority of tests are either - e2e tests in playwright, most of them make assertions about DOM etc, as well as a few screenshot tests - unit tests for "library code" (for example custom code for working with dates etc). all of these are basically the format expect(someFunction(input)).toEqual(expectedOutput)
R
raphico15d ago
Thank you all for your feedback! Much appreciated 👍
Want results from more Discord servers?
Add your server
More Posts
Create t3 app with nextauth and new router problemsI have a question regarding the t3-createapp with nextauth. In what file do I put my <SessionProvidModals failing from tutorialhttps://github.com/mchisolm0/gallery/pull/2 I am having trouble getting the modals/app router workiBenefits of using auto incrementing primary keys?Is there any benefit of using auto incrementing columns as primary keys in postgres when I have anotIs Tanstack Query needed when using Next Route Handlers?Basically what it says. To my understanding a [Route Handler](https://nextjs.org/docs/app/building-yt3 env doesn't seem to work with docker compose buildI'm working to validate my application before pushing it to my CI/CD pipeline. I keep getting faileNextAuth - Email Provider Breaking Google Provider!Howdy, Some users of my app (app.getriver.io) started reporting not being able to log in to our appVSCode Import Autocomplete Purgatory (Relative, absolute, and barrel paths)I hope I'm missing some easy setting, otherwise this UI seems pretty terrible. Why does the autocompThe In App vs NextAuth problemIf you open the app link from a mobile app (like discord/telegram) and it opens in the in-app browseTypeErrorinitialTree is not iterable in Modern React Tutorial vidThe images map correctly until I try clicking on one, so I think the error may be misleading me. I T3 Roadmap? What would you recommend?I recently landed an internship, and they use the T3 Stack. I already had experience with JS, React,are there any better logs for nextJS that are in Englishjust spent 30min playing around with this and trying to work out the problem all I did was copy and Should I report a bug to a federal(-ish) university without hopes of a bug bounty?I live in nigeria, I attend national open university of nigeria. I recently found out a bug which alFork bombHi, i saw the new video from theo about the AI interview, and on the video he said to the AI to exeCommunication with server and client <nextjs>i have a webhook which calls nextjs api, can that api call do something which triggers an action onReact Native Data Loader libraryDoes anyone know of any good data loader libraries that will prevent waterfalls in React Native? I kNext.js as a client API choiceHaving watched all theo's videos regarding next and APIs (mainly tRPC and server actions), i got the