Sam Landfried

Testing in Node - Stubs and Spies

Sam Landfried | Feb 04, 2019

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

Subscribers Only

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

Subscribers Only

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

Need Help?

If you get stuck, try starting a discussion with Big Nerd Ranch experts in the community tab.

Skill Pack

This screencast is part of a skill pack called Testing in Node.

Related Screencasts

Explore other screencasts related to this topic.