Let’s start JEST! React Native Unit testing tool

Sanjana Human In Tech
2 min readJan 31, 2021

--

Unit Testing? Developers can do testing…

Unit testing is a software testing process by which functions, methods, classes, and user interface elements are tested to determine whether they are fit in the source code as per application functionality developed.

Recently I faced a challenge to understand Jest Framework or any new framework which takes time for me to do it and time to think about how can I write test cases for nested functions, how to pass parameters and how to call a method which is defined in another class.

I wanted to highlight one process in software is Test Driven Development- TDD. So TDD is a software development approach in which test cases are developed to specify and validate what code will do. Testcases for each functionality are created and tested first and if the test case is failed, then new code is written to pass the test and making code bug — free.

so after failing at it, I started what is Jest and Enzyme? By Defination;

Jest is a Javascript testing framework used by Facebook to test services and react applications.
Enzyme is a Javascript testing framework for React that allows to test utility methods for rendering a component, finding elements, and interacting with elements.

There are two types of testing.

  1. UI Testing
  2. Functional Testing

In UI testing, check element is present or not in the DOM tree or the element is present at the nth position also any click of UI element is present it or not.

In Functional testing where we check the method is declared, the method should be in a particular file, proper parameters should be passed, passing mock value to the variable to execute the code.

There are two types of test cases

  1. Positive test case
  2. Negative test case

I will be covering in the next blog how to write test case snippets.

Thank you for reading, hit the clap button.

If you have any queries please post them in a comment.

--

--

Sanjana Human In Tech
Sanjana Human In Tech

Written by Sanjana Human In Tech

A React Native front-end enthusiast and dedicated development engineer, eager to expand knowledge on development techniques and collaborate with others.

Responses (1)