Unit Testing in JavaScript: SinonJS

Unit Testing
  • 23 Videos | 2h 38m 31s
  • Includes Assessment
  • Earns a Badge
Likes 5 Likes 5
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.

WHAT YOU WILL LEARN

  • 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

IN THIS COURSE

  • Playable
    1. 
    Course Overview
    2m
    UP NEXT
  • Playable
    2. 
    Installing Mocha and Sinon
    3m 59s
  • Locked
    3. 
    Setting up the Object under Test
    4m 25s
  • Locked
    4. 
    Using Fakes
    7m 45s
  • Locked
    5. 
    Using Fakes with Behavior
    7m 12s
  • Locked
    6. 
    Testing the Order with Fakes
    8m 5s
  • Locked
    7. 
    Testing Errors and Callbacks with Fakes
    10m 3s
  • Locked
    8. 
    Using Fakes with Promises
    4m 24s
  • Locked
    9. 
    Using Anonymous Spies for Testing
    8m 55s
  • Locked
    10. 
    Wrapping Spies around Functions
    4m 13s
  • Locked
    11. 
    Spying on Methods of an Object
    5m 23s
  • Locked
    12. 
    Using Sandboxes to Spy on Objects
    5m 48s
  • Locked
    13. 
    Spying on Getters and Setters
    2m 10s
  • Locked
    14. 
    Using Spies to Test PubSub and jQuery
    5m 51s
  • Locked
    15. 
    Configuring Behavior with Stubs
    10m 28s
  • Locked
    16. 
    Stubbing Object Methods
    7m 36s
  • Locked
    17. 
    Creating Stub Objects without Constructors
    5m 43s
  • Locked
    18. 
    Mocking Objects and Functions
    8m 55s
  • Locked
    19. 
    Observing Function Invocations with Spy Calls
    9m 32s
  • Locked
    20. 
    Controlling Time Using Fake Timers
    10m 1s
  • Locked
    21. 
    Using Timers with Multiple Async Operations
    6m 13s
  • Locked
    22. 
    Testing with Sandboxes
    8m 3s
  • Locked
    23. 
    Course Summary
    1m 16s