Sam Landfried

Testing in Node - Testing with a Database (Part 1)

Sam Landfried | Feb 04, 2019

Testing code creates more reliable and maintainable applications. Testing a complex app with multiple dependencies can be, well, complex. A common dependency that needs to be managed in a test environment is a database. In this screencast, you’ll learn how to incorporate a database into your tests to increase their value.

After this screencast, you'll be able to:

- Test parts of your application that rely on records existing in your database.
- Use root-level lifecycle hooks in Mocha to improve control of test execution.
- Write meaningful integration tests.

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

For the More Curious...

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.

Testing in Node

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

Testing in Node - Basics

8 minutes

The options available to the Node developer setting up testing for the first time can be overwhelming. There are several tools to choose from, and they can be configured in multiple ways.

Testing in Node - Stubs and Spies

7 minutes

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.

Testing in Node - Coverage

6 minutes

Testing code creates more reliable and maintainable applications. When adding tests to an existing codebase, test coverage reports can help expose which parts of the app are untested. When creating a new test suite alongside a new app, test coverage reports can help guide the creation of valuable tests.

Testing in Node - Integration Testing (Part 1)

8 minutes

Integration tests describe a server’s overall behavior and capabilities. These tests can quickly expose failing systems, help developers isolate bugs and make server-sized refactors safer. In this screencast, we’ll show you how to configure the Chai HTTP extension with the existing test suite for the Chattrbox app.

Testing in Node - Integration Testing (Part 2)

6 minutes

Integration tests describe a server’s overall behavior and capabilities. These tests can quickly expose failing systems, help developers isolate bugs and make server-sized refactors safer.

Testing in Node - Testing with a Database (Part 1)

6 minutes

Testing code creates more reliable and maintainable applications. Testing a complex app with multiple dependencies can be, well, complex. A common dependency that needs to be managed in a test environment is a database.

Testing in Node - Testing with a Database (Part 2)

5 minutes

Creating database entities for tests quickly becomes unmanageable as data models become more complex. Factory Girl allows us to quickly create records in our database that easily grow with our application.

Related Screencasts

Explore other screencasts related to this topic.

Testing in Node - Basics

8 minutes

The options available to the Node developer setting up testing for the first time can be overwhelming. There are several tools to choose from, and they can be configured in multiple ways.

Testing in Node - Integration Testing (Part 1)

8 minutes

Integration tests describe a server’s overall behavior and capabilities. These tests can quickly expose failing systems, help developers isolate bugs and make server-sized refactors safer. In this screencast, we’ll show you how to configure the Chai HTTP extension with the existing test suite for the Chattrbox app.

Load Screens in React

5 minutes

Load screens provide a visual indicator to users that data is being fetched and a useful reminder that the app isn’t frozen. They also can prevent unwanted user interaction with your site. This screencast walks through building a simple load screen in React that will improve user experiences

Testing in Node - Coverage

6 minutes

Testing code creates more reliable and maintainable applications. When adding tests to an existing codebase, test coverage reports can help expose which parts of the app are untested. When creating a new test suite alongside a new app, test coverage reports can help guide the creation of valuable tests.

Testing in Node - Integration Testing (Part 2)

6 minutes

Integration tests describe a server’s overall behavior and capabilities. These tests can quickly expose failing systems, help developers isolate bugs and make server-sized refactors safer.

Testing in Node - Stubs and Spies

7 minutes

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.