Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

testcontainers

Package Overview
Dependencies
Maintainers
0
Versions
249
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

testcontainers

Testcontainers is a NodeJS library that supports tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container

  • 10.14.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
176K
decreased by-58.43%
Maintainers
0
Weekly downloads
 
Created

What is testcontainers?

The testcontainers npm package is a library that provides lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container. It is primarily used for integration testing, allowing developers to run tests against real instances of services without the overhead of managing those services manually.

What are testcontainers's main functionalities?

Running a PostgreSQL container

This feature allows you to run a PostgreSQL container for testing purposes. The code sample demonstrates how to start a PostgreSQL container with a specified password and expose the default port.

const { GenericContainer } = require('testcontainers');
(async () => {
  const container = await new GenericContainer('postgres')
    .withEnv('POSTGRES_PASSWORD', 'password')
    .withExposedPorts(5432)
    .start();
  console.log(`PostgreSQL started on port ${container.getMappedPort(5432)}`);
})();

Running a Redis container

This feature allows you to run a Redis container for testing purposes. The code sample demonstrates how to start a Redis container and expose the default port.

const { GenericContainer } = require('testcontainers');
(async () => {
  const container = await new GenericContainer('redis')
    .withExposedPorts(6379)
    .start();
  console.log(`Redis started on port ${container.getMappedPort(6379)}`);
})();

Running a custom Docker container

This feature allows you to run any custom Docker container for testing purposes. The code sample demonstrates how to start a custom Docker container and expose a specified port.

const { GenericContainer } = require('testcontainers');
(async () => {
  const container = await new GenericContainer('your-custom-image')
    .withExposedPorts(8080)
    .start();
  console.log(`Custom container started on port ${container.getMappedPort(8080)}`);
})();

Other packages similar to testcontainers

Keywords

FAQs

Package last updated on 05 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc