Unit Testing in JavaScript: Mocha & Chai

Expected Duration
Lesson Objectives
Course Number
Expertise Level


This 12-video course offers a detailed exploration of the Chai assertion framework, an assertion library available in JS (Javascript) to perform unit testing. In this course, you will learn how to install and set up the Chai assertion library on your computer, and learn to use two kinds of application programming interfaces (APIs) that Chai offers for assertions. Learners will examine Chai APIs for both test-driven development and behavior-driven development, and will write unit tests by using the classic API. Learn to use the classic assertion API as well as the Should and Expect API in Chai to test numbers, Booleans, strings, objects and object properties, and arrays. Explore how to use Should to chain multiple assertions together. Then learn how to run tests on simple data types, including Boolean strings and numbers, and on complex data types such as arrays and objects, all using Chai, and examine behavior-driven development by using the Should and Expect APIs. This course compares test-driven development and behavior-driven development. Finally, explore the Expect API.

Expected Duration (hours)

Lesson Objectives

Unit Testing in JavaScript: Mocha & Chai

  • discover the key concepts covered in this course
  • install the Chai library on your local machine
  • use assertions to test boolean values
  • compare numeric values using assert
  • performing string comparisons using assert
  • describe the assertions that can be used to test objects and their properties
  • use arrays and elements in arrays using assert
  • compare and contrast the should and expect APIs in Chai
  • test different data types using should
  • test different data types using expect
  • perform asynchronous function testing using expect
  • summarize the key concepts covered in this course
  • Course Number:

    Expertise Level