Appearance
Fresh
Testcontainers for Node.js
Back
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
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
Create the project Set up a Node.js project with a PostgreSQL-backed customer repository.
Write tests Write integration tests using Testcontainers for Node.js and Jest with a real PostgreSQL database.
Run tests Run your Testcontainers-based integration tests and explore next steps.