Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

77
Vistas
Testing Library React vs Jest

I have a really big application with react(lot of pages, modals, tables,etc) and I'm using redux-saga for managing the state. I have a lote of stores and almost in all the components I use the useSelector method for getting the data from the store and many hooks inside them because of logic.

I want to start testing the application, specially to avoid that the app crashes when there is data undefined, invalid, etc. What library do you recommend me to apply in this case ?

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

React Testing Library is not an alternative to Jest, because they need each other and every one of them has a clear task.

Jest is a test runner, which gives you the ability to run tests with Jest from the command line. In addition, Jest offers you functions for test suites, test cases, and assertions. React Testing Library, in contrast to Jest, is one of the testing libraries to test React components.

If you are using create-react-app, Jest (and React Testing Library) comes by default with the installation. If you are using a custom React setup, you need to install and set up Jest (and React Testing Library) yourself.

You might want to look for more on: https://jestjs.io/docs/en/tutorial-react & https://testing-library.com/docs/react-testing-library/intro/. Also you can follow up for more on issues and disscusions on github channels of the libraries.

over 4 years ago · Santiago Trujillo Denunciar

0

React Testing Library and Jest both have different responsibilities "react testing library" is not a test runner meaning when u enter command npm test or npm run test it is jest responsibility that collect all the files ending with .test.js and runs each test case and show pass and fail results in your console like below

enter image description here

react testing library provides you function to catch dom element and perform some action below are some of its function

render, fireEvent, waitFor, screen

you can also use Enzyme(another popular testing library) for such function to access dom element

EXTRA: developer often confuse among

  • jest
  • react-testing-library
  • Enzyme

Here Enzyme and react-testing-library are two similar things and alternatives to each other means you can use

  • enzyme with jest or
  • react-testing-library with jest
  • you can also use all three i.e react-testing-library+Enzyme with jest
  • but you can not use Enzyme and react-testing-library without jest or any other test runner eg: Mocha

where jest(testing-framework) will collect all .test.js files execute all the test cases and put the output in console with detail like how many pass and fail and react-testing-library or enzyme(both are testing library) will help you to perform event and accessing dom element

over 4 years ago · Santiago Trujillo Denunciar

0

JEST

"Jest is a delightful JavaScript Testing Framework with a focus on simplicity. It works with projects using: Babel, TypeScript, Node, React, Angular, Vue, and more!"

src: jest

TLDR: Jest allows you to test any of the above without much boilerplate quickly. As a framework, the framework's code calls your test code. Jest looks for changes made to the code to run specific test cases etc. You can write test's for React just using Jest (react documentation)

React Testing Library

"The React Testing Library is a very light-weight solution for testing React components. It provides light utility functions on top of react-dom and react-dom/test-utils, in a way that encourages better testing practices". src: RTL

TLDR: It is a library (i.e., you call the code). It provides some utilities on top of just using Jest and the default react-dom/jest-utils that help us write tests quickly and with less boilerplate (using multiple act() calls etc.) and closer to real-life use (accessibility)

Use RTL with mock server workers to make your life easier for large projects.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda