New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

testcontainers-mailhog

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

testcontainers-mailhog

A Testcontainers implementation for Mailhog

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
4
Maintainers
1
Weekly downloads
 
Created
Source

Testcontainers-Mailhog

NPM version

A testcontainers for mailhog

Install

https://www.npmjs.com/package/testcontainers-mailhog

npm i -D testcontainers-mailhog

Configuration

Reference

Logs

  • DEBUG=testcontainers Enable testcontainers logs
  • DEBUG=testcontainers:containers Enable container logs
  • DEBUG=testcontainers* Enable all logs

Testcontainers

  • TESTCONTAINERS_RYUK_DISABLED=true Disable ryuk
  • RYUK_CONTAINER_IMAGE=registry.mycompany.com/mirror/ryuk:0.3.0 Custom image for ryuk

Utility Methods of StartedMailhogContainer

  • .getAllMessages() Lists all messages excluding message content
  • .getMessage(messageId) Returns an individual message including message content
  • .deleteAllMessages() Deletes all messages
  • .deleteMessage(messageId) Delete an individual message
  • .getMappedSmtpPort() Get mapped smtp port, for configure smtp client
  • .getMappedApiPort() Get mapped api port, if u want to invoke api manually

Usage

Test with vitest

import { afterAll, afterEach, beforeAll, describe, expect, test } from 'vitest'

import {
  MailhogContainer,
  StartedMailhogContainer
} from 'testcontainers-mailhog'

describe('Mailing test', () => {
  let mailhogContainer: StartedMailhogContainer

  beforeAll(async () => {
    const imageName = 'harbor.yourcompany.com/mailhog'
    mailhogContainer = await new MailhogContainer(imageName).start()
  })

  afterAll(async () => {
    await mailhogContainer.stop()
  })

  afterEach(async () => {
    await mailhogContainer.deleteAllMessages()
  })

  test('some case with mailing', async () => {
    // const smtpUrl = `${mailhogContainer.getHost()}:${mailhogContainer.getMappedSmtpPort()}`
    // ...
  })
})

See test cases for the example with nodemailer

Keywords

testcontainers

FAQs

Package last updated on 23 Nov 2022

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