Skip to main content

One post tagged with "tutorials"

View All Tags

Testing Postgres and Node.js APIs with Jest

Alex Pearson

Alex Pearson

Platter CTO

Testing applications and their databases is tricky but important.

When done correctly, tests that include real database queries help to reassure developers that their features are implemented correctly across the entire stack. When done poorly, database-dependent test suites can be slow, flaky, and even dangerous to run.

In this post, we'll explore strategies for keeping data-dependent tests realistic, consistent, isolated, and fast by running tests against short-lived, isolated databases. The concepts in this post will apply to any application that depends on a database, but we'll be using Node for our runtime and Jest as our test runner to explore different strategies.