Skip to content
Fresh

Testcontainers for Node.js

Back

Guides

Getting started with Testcontainers for Node.js

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

JavaScript Testing with Docker

15 minutes

1

Create the project

2

Write tests

3

Run tests

« Back to all guides

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 complete15 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.