DEV Community

Kuldeep Nageshwar
Kuldeep Nageshwar

Posted on

Learn react-testing-library for test react projects

Here I am not going to give you the basic and usual tutorial for
Learn to test in reacting with use of jest and react-testing-library instead I going to list some resource and trick to get you to hand dirty and make ownself perfect to give 100 % coverage on Sonarqube.
Sonarqube is a code analysis tool to Catch bugs and vulnerabilities in your app, with thousands of automated Static Code Analysis rules.
Sonarqube gives you an analysis of your test case as code coverage.
you can see your code coverage on the dashboard of your Sonarqube server.

while writing a test case you have right your code inside a describe blog and inside describe block you must use it or test function to write your test case.

first Trick

I always get confused or stuck while writing my test case that how to select and specific element.
So for that, you can use this testing-playground testin-playgorund given by react-testing-library.

second trick

while writing test cases you have to write an assertion but some you get stuck that how we can test code so you can use the docs
given by jest in the official documentation expect

Top comments (0)