Today in class, we discussed unit testing in great detail. Unit testing is an automated testing technique to check how different units like methods of classwork with different inputs. One remarkable importance of unit testing to new developers is the confidence to update code after proving that the small units pass all the tests.
During my Software design and Implementation course, we talked about unit testing with Python; we wrote different test cases in a file that imported the file to be tested. However, one thing that shocked me as we discussed unit testing today is the fact that test cases are written before a developer begins coding. I have always thought that tests are written after coding the different functions to ensure that the units under test run as expected. Although this was not far from the reason why tests are written before the code, the aim of writing tests before coding is to enable the developer plan for the different boundary conditions included in the test cases before, they write the code.
To unit test our ReactJS projects, we used Jest, which is a command-line JavaScript unit testing framework by Facebook. With Jest, each file.tsx had a corresponding file.test.tsx that contained all the test cases for the application. A fascinating feature of Jest is the ability to unit test the UI through the command line by enabling the creation of a Document. This is an excellent feature in web development because it eliminates manual testing of different buttons' actions.
No comments:
Post a Comment