Fix flaky playwright tests (#28959)
* Fix playwright flaky tests Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Wipe mailhog between test runs Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Delint Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
committed by
GitHub
parent
f99d7ce2bb
commit
e14a3b64c3
@@ -7,22 +7,25 @@ Please see LICENSE files in the repository root for full details.
|
||||
|
||||
import { test as base } from "@playwright/test";
|
||||
import mailhog from "mailhog";
|
||||
import { GenericContainer, Network, StartedNetwork, StartedTestContainer, Wait } from "testcontainers";
|
||||
import { Network, StartedNetwork } from "testcontainers";
|
||||
import { PostgreSqlContainer, StartedPostgreSqlContainer } from "@testcontainers/postgresql";
|
||||
|
||||
import { SynapseConfigOptions, SynapseContainer } from "./testcontainers/synapse.ts";
|
||||
import { ContainerLogger } from "./testcontainers/utils.ts";
|
||||
import { StartedMatrixAuthenticationServiceContainer } from "./testcontainers/mas.ts";
|
||||
import { HomeserverContainer, StartedHomeserverContainer } from "./testcontainers/HomeserverContainer.ts";
|
||||
import { MailhogContainer, StartedMailhogContainer } from "./testcontainers/mailhog.ts";
|
||||
|
||||
interface TestFixtures {
|
||||
mailhogClient: mailhog.API;
|
||||
}
|
||||
|
||||
export interface Services {
|
||||
logger: ContainerLogger;
|
||||
|
||||
network: StartedNetwork;
|
||||
postgres: StartedPostgreSqlContainer;
|
||||
|
||||
mailhog: StartedTestContainer;
|
||||
mailhogClient: mailhog.API;
|
||||
mailhog: StartedMailhogContainer;
|
||||
|
||||
synapseConfigOptions: SynapseConfigOptions;
|
||||
_homeserver: HomeserverContainer<any>;
|
||||
@@ -30,7 +33,7 @@ export interface Services {
|
||||
mas?: StartedMatrixAuthenticationServiceContainer;
|
||||
}
|
||||
|
||||
export const test = base.extend<{}, Services>({
|
||||
export const test = base.extend<TestFixtures, Services>({
|
||||
logger: [
|
||||
// eslint-disable-next-line no-empty-pattern
|
||||
async ({}, use) => {
|
||||
@@ -79,24 +82,20 @@ export const test = base.extend<{}, Services>({
|
||||
|
||||
mailhog: [
|
||||
async ({ logger, network }, use) => {
|
||||
const container = await new GenericContainer("mailhog/mailhog:latest")
|
||||
const container = await new MailhogContainer()
|
||||
.withNetwork(network)
|
||||
.withNetworkAliases("mailhog")
|
||||
.withExposedPorts(8025)
|
||||
.withLogConsumer(logger.getConsumer("mailhog"))
|
||||
.withWaitStrategy(Wait.forListeningPorts())
|
||||
.start();
|
||||
await use(container);
|
||||
await container.stop();
|
||||
},
|
||||
{ scope: "worker" },
|
||||
],
|
||||
mailhogClient: [
|
||||
async ({ mailhog: container }, use) => {
|
||||
await use(mailhog({ host: container.getHost(), port: container.getMappedPort(8025) }));
|
||||
},
|
||||
{ scope: "worker" },
|
||||
],
|
||||
mailhogClient: async ({ mailhog: container }, use) => {
|
||||
await use(container.client);
|
||||
await container.client.deleteAll();
|
||||
},
|
||||
|
||||
synapseConfigOptions: [{}, { option: true, scope: "worker" }],
|
||||
_homeserver: [
|
||||
|
||||
Reference in New Issue
Block a user