Unit Testing with Jest

In order to do this activity, you must have completed the following:

  1. Setting up the project
  2. Creating custom modules

PART 1

Notes from the (first) video

To install jest as a dev dependency

npm install jest --save-dev

Notice how it gets saved in package.json, in the devDependencies section.

To run the test:

npx jest .\tests\sample.test.js

Other quick notes before moving on:

  1. Jest makes heavy use of callbacks
  2. You can nest describe() calls to organize your tests for each function
  3. The it() function is an alias for the test() function
  4. Learn how to use it()/test() to run individual tests
  5. The expect() function
  6. Here's a reference on Jest matchers (toBe(), .not, toBeGreaterThan(), etc.)

PART 2