Lab 8 Blog

In this project, I used jest as a unit testing framework, which Facebook created. It makes it easier to test UIs and javascript functions. It has features like a built-in assertion library, code coverage, and mocking. It is now a full set of tools that can be used for my JavaScript project. By running multiple test suites at the same time, Jest can speed up the testing process as a whole. I choose Jest as my testing framework because using mocking in test cases was important to me when testing functions, as it helped me to test values that are not real.


To set up my project. First I ran the command 

npm install

to install all module dependancies. Then I ran the command 

npm install --save-dev jest

to install the jest module as dev dependancies. Then I added the script

"scripts": { "test": "jest" }


I learned while writing my test cases that making test cases for each function was unnecessary. Some of my functions were calling other functions. Also, I realized that testing for HTML is very sensitive when providing an extra space might not matter when testing it by a human, but it matters when getting tested in jest. I also learned that only functions need to be tested. Variables outside of functions don't need to be tested.


When I was making test cases I found some interesting bugs in my functions. My functions were not checking for undefined, null or empty values passed to the parameter of the functions.


This was my first time testing with jest. Throughout this process, I have learned how to test my functions using jest to make unit test cases. This is a better way of testing than a human because using jest is quicker to create test cases than for a human to manually test. Some test cases might not be able to be tested by a human. 






Comments

Popular posts from this blog

Octoberfest Week 2 Blog

Lab 9 Blog