Files
ThreadNet-Web/playwright/testcontainers/mailpit.ts
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

34 lines
1.1 KiB
TypeScript
Raw Normal View History

2025-01-13 09:32:00 +00:00
/*
Copyright 2024 New Vector Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
2025-02-05 13:25:06 +00:00
import { AbstractStartedContainer, GenericContainer, type StartedTestContainer, Wait } from "testcontainers";
import { MailpitClient } from "mailpit-api";
2025-01-13 09:32:00 +00:00
export class MailhogContainer extends GenericContainer {
constructor() {
super("axllent/mailpit:latest");
2025-01-13 09:32:00 +00:00
this.withExposedPorts(8025).withWaitStrategy(Wait.forListeningPorts()).withEnvironment({
MP_SMTP_AUTH_ALLOW_INSECURE: "true",
MP_SMTP_AUTH_ACCEPT_ANY: "true",
});
2025-01-13 09:32:00 +00:00
}
public override async start(): Promise<StartedMailhogContainer> {
return new StartedMailhogContainer(await super.start());
}
}
export class StartedMailhogContainer extends AbstractStartedContainer {
public readonly client: MailpitClient;
2025-01-13 09:32:00 +00:00
constructor(container: StartedTestContainer) {
super(container);
this.client = new MailpitClient(`http://${container.getHost()}:${container.getMappedPort(8025)}`);
2025-01-13 09:32:00 +00:00
}
}