Pursuit Logo

Unit Testing Lab

Making your code better, one test at a time.

Learning Objectives

  • Practice creating tests and thinking of testing for small functions
  • Understanding the advantages of testing

Getting Started

  • Clone this repo
  • Initialize an npm project inside the cloned repo with npm init -y
  • Install Jest as a development dependency npm install -D jest
  • Modify the test script in package.json. To be test: "jest"
  • Inspect the provided JavaScript functions.
  • Create two files objectFunctions.test.js and labFunctions.test.js.
  • Read the function description and the tests suggestions in the function's comments.
  • For each function write tests that verify the given function works as expected. Make sure to test with a few different inputs and expect the desired output
  • Group function's tests in describe() blocks. One describe block per function.
  • Run your tests with npm test

Note:

  • If you can think of any other test cases you want to add for any of the functions your are highly encouraged to add them.
  • If you find any mistakes in the code provided, fix it.

Submission

Submit a pull request to this repo.