Unit Testing in JavaScript: SinonJS


Overview/Description
Expected Duration
Lesson Objectives
Course Number
Expertise Level



Overview/Description

Learners can explore the Sinon JS (Javascript) library in this 23-video course. You will learn how to install Sinon library, and will explore the use of fakes, spies, stubs, and mocks in Sinon. Observe how to test code that is part of your application, and replace invocations to other components by using fix. You will learn to create a fake function, and to define the behavior of these functions. Next, you will examine spies, which support all operations that fake support, and allow you to spy on methods that you invoke on objects. Learners continue by examining how stubs can be used to create objects without invoking the objects constructor, and how configuring stub behavior allows us to test specific code paths. You will learn to use fake timers and sandboxes to write unit tests, and how to configure fakes and spies with behavior. Finally, you will learn to set up the expectations for your mocks, and you will control time using fake timers for asynchronous operations which use promises in JS.



Expected Duration (hours)
2.5

Lesson Objectives

Unit Testing in JavaScript: SinonJS

  • discover the key concepts covered in this course
  • install Mocha and Sinon on your local machine
  • create an object to be used in test cases
  • use fakes to record function invocations
  • configure fakes with specific behavior
  • test the order of function invocations using fakes
  • recognize how to test errors and callbacks with fakes
  • perform asynchronous tests using fakes with promises
  • create and use anonymous spies for testing
  • wrap spies around existing functions
  • spy on specific methods of an object
  • describe the use of sandboxes for testing
  • perform testing using spies on object getters and setters
  • test real world components using spies
  • configure stub behavior in test cases
  • create stubs for object methods
  • instantiate objects without invoking object constructors
  • perform testing using mocks and set expectations
  • use spy calls to test function invocations
  • control time in tests to make asynchronous testing easy
  • use fake timers with multiple async functions
  • use sandboxes to simplify testing
  • summarize the key concepts covered in this course
  • Course Number:
    it_aputjsdj_05_enus

    Expertise Level
    Intermediate