Hacer test de función con Mock en jest ['ESP','ENG']

Cuando realiza test de programación con javascript por lo general esperamos datos certeros u algún tipo de dato como respuestas, esto es muy útil si el dato no genera ninguna demora en la respuesta u si algo fácil de manejar, pero no es conveniente hacer esto cuando se trata de llamadas a datos de servidores porque la repuestas puede ser bastante grande y esto no es lo que uno busca evaluar con los test, sino el comportamiento de la función.

When you perform programming tests with javascript, we generally expect accurate data or some type of data as responses, this is very useful if the data does not generate any delay in the response or something easy to handle, but it is not convenient to do this when It deals with calls to server data because the response can be quite large and this is not what one seeks to evaluate with the tests, but rather the behavior of the function.
Utilizar “mock” para los test significa que la respuesta que debe dar la función es la misma que se ingresa en el test, por lo tanto el test solo evalúa que el comportamiento sea el esperado y en caso de ocurrir errores también, de esta manera se verifica que la función asíncrona fue bien escrita.
Using “mock” for the tests means that the response that the function must give is the same as that entered in the test, therefore the test only evaluates that the behavior is as expected and also if errors occur, in this way It verifies that the asynchronous function was written well.

mock2.jpg



0
0
0.000
1 comments
avatar

Thanks for your contribution to the STEMsocial community. Feel free to join us on discord to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support. 
 

0
0
0.000