Unit Testing in JavaScript: SinonJS
Unit Testing
| Intermediate
- 23 Videos | 2h 28m 1s
- Includes Assessment
- Earns a Badge
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 courseinstall Mocha and Sinon on your local machinecreate an object to be used in test casesuse fakes to record function invocationsconfigure fakes with specific behaviortest the order of function invocations using fakesrecognize how to test errors and callbacks with fakesperform asynchronous tests using fakes with promisescreate and use anonymous spies for testingwrap spies around existing functionsspy on specific methods of an objectdescribe the use of sandboxes for testing
-
perform testing using spies on object getters and setterstest real world components using spiesconfigure stub behavior in test casescreate stubs for object methodsinstantiate objects without invoking object constructorsperform testing using mocks and set expectationsuse spy calls to test function invocationscontrol time in tests to make asynchronous testing easyuse fake timers with multiple async functionsuse sandboxes to simplify testingsummarize the key concepts covered in this course
IN THIS COURSE
-
1.Course Overview2mUP NEXT
-
2.Installing Mocha and Sinon3m 59s
-
3.Setting up the Object under Test4m 25s
-
4.Using Fakes7m 45s
-
5.Using Fakes with Behavior7m 12s
-
6.Testing the Order with Fakes8m 5s
-
7.Testing Errors and Callbacks with Fakes10m 3s
-
8.Using Fakes with Promises4m 24s
-
9.Using Anonymous Spies for Testing8m 55s
-
10.Wrapping Spies around Functions4m 13s
-
11.Spying on Methods of an Object5m 23s
-
12.Using Sandboxes to Spy on Objects5m 48s
-
13.Spying on Getters and Setters2m 10s
-
14.Using Spies to Test PubSub and jQuery5m 51s
-
15.Configuring Behavior with Stubs10m 28s
-
16.Stubbing Object Methods7m 36s
-
17.Creating Stub Objects without Constructors5m 43s
-
18.Mocking Objects and Functions8m 55s
-
19.Observing Function Invocations with Spy Calls9m 32s
-
20.Controlling Time Using Fake Timers10m 1s
-
21.Using Timers with Multiple Async Operations6m 13s
-
22.Testing with Sandboxes8m 3s
-
23.Course Summary1m 16s
EARN A DIGITAL BADGE WHEN YOU COMPLETE THIS COURSE
Skillsoft is providing you the opportunity to earn a digital badge upon successful completion of this course, which can be shared on any social network or business platform
Digital badges are yours to keep, forever.