How to use testcontainers - 1 common examples

To help you get started, we’ve selected a few testcontainers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github strongloop / loopback-next / acceptance / extension-logging-fluentd / src / __tests__ / fixtures / fluentd.docker.ts View on Github external
async function startFluentd() {
  if (process.env.FLUENTD_SERVICE_HOST != null) return;
  const container = await new GenericContainer(
    'fluent/fluentd',
    'v1.7.4-debian-1.0',
  )
    .withName('fluentd_lb4')
    .withExposedPorts(24224, 9880)
    .withEnv('FLUENTD_CONF', 'fluentd.conf')
    .withBindMount(ETC_DIR, '/fluentd/etc', 'ro')
    .start();
  process.env.FLUENTD_SERVICE_HOST = container.getContainerIpAddress();
  process.env.FLUENTD_SERVICE_PORT_TCP = container
    .getMappedPort(24224)
    .toString();
  process.env.FLUENTD_SERVICE_PORT_HTTP = container
    .getMappedPort(9880)
    .toString();
  return container;

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

MIT
Latest version published 16 days ago

Package Health Score

86 / 100
Full package analysis

Popular testcontainers functions