Testing in Node - Stubs and Spies

By Sam Landfried on Feb 04, 2019


About

Testing code creates more reliable and maintainable applications. It’s not always a straightforward process, though. Stubs and spies give us more control of what we can test and how our code behaves when we test it. Adding them to a test suite can solve several testing problems.

In this screencast, we’ll show you how to integrate Sinon, a popular JavaScript doubles library, into your test suite. We’ll also show you how to write spies and stubs with Sinon in a practical example from one of the projects students create in our web development course.

After this screencast, you'll be able to…

- Test the details of how a function was called during a test with declarative assertions.
- Prevent certain parts of your code from executing during tests.

Familiarity with Node.js and package managers (npm or yarn) is recommended.

For the More Curious...

Sinon.js
BNR Guide to Front-End Web Development
Full Stack Courses

Transcript

Transcripts are only available for subscribers. Create an account today to access our collection of screencasts, skill packs, and more.

Downloads

Project files are only available for subscribers. Create an account today to access our collection of screencasts, skill packs, and more.

Comments