Share feedback
Answers are generated based on the documentation.

Getting started with Testcontainers for Node.js

Table of contents

Learn how to create a Node.js application and test database interactions using Testcontainers for Node.js with a real PostgreSQL instance.
Time to complete 15 minutes

In this guide, you will learn how to:

  • Create a Node.js application that stores and retrieves customers from PostgreSQL
  • Write integration tests using Testcontainers and Jest
  • Run tests against a real PostgreSQL database in a Docker container

Prerequisites

  • Node.js 18+
  • npm
  • A Docker environment supported by Testcontainers
Note

If you're new to Testcontainers, visit the Testcontainers overview to learn more about Testcontainers and the benefits of using it.

Modules

  1. Create the project

    Set up a Node.js project with a PostgreSQL-backed customer repository.

  2. Write tests

    Write integration tests using Testcontainers for Node.js and Jest with a real PostgreSQL database.

  3. Run tests

    Run your Testcontainers-based integration tests and explore next steps.