mirror of
https://github.com/hanzoai/team.git
synced 2026-09-30 01:57:35 +00:00
* add testcontainers to playwright-lib * include retry mechanism for transient failures * - Introduced a new command `testcontainers:up` in package.json to run Playwright tests with Testcontainers. - Created a standalone Playwright configuration file `playwright.testcontainers-up.config.ts` for managing Testcontainers. - Added a no-op test `testcontainers_up.spec.ts` to ensure the Testcontainers stack is up during the test run. - Implemented a global setup script `testcontainers_up_global_setup.ts` to start and stop the Testcontainers stack. - Updated dependencies in package.json, including adding `chalk` for logging. * fix package-lock * fix tsc and restore waiting for all migrations to complete --------- Co-authored-by: Mattermost Build <[email protected]>
33 lines
1.3 KiB
TypeScript
33 lines
1.3 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import chalk from 'chalk';
|
|
|
|
import {baseGlobalSetup, startStack, stopStack, testConfig} from '@mattermost/playwright-lib';
|
|
|
|
async function globalSetup() {
|
|
try {
|
|
// With PW_USE_TESTCONTAINERS=true, bring up the server + dependencies via Testcontainers
|
|
// before pinging it. No-op otherwise, when a server is expected to already be running.
|
|
await startStack();
|
|
await baseGlobalSetup();
|
|
} catch (error: unknown) {
|
|
// eslint-disable-next-line no-console
|
|
console.error(chalk.cyan('[testcontainers]'), error);
|
|
// Whatever startStack() managed to bring up (e.g. baseGlobalSetup() failed after the
|
|
// stack itself came up fine) shouldn't linger just because we're about to throw.
|
|
await stopStack();
|
|
const message = error instanceof Error ? error.message : String(error);
|
|
const hint = testConfig.useTestContainers
|
|
? 'Check the container named above and its logs under logs/.'
|
|
: `Ensure the server at ${testConfig.baseURL} is running and accessible.`;
|
|
throw new Error(chalk.red(`[testcontainers] Global setup failed: ${message}\n${hint}`));
|
|
}
|
|
|
|
return async function () {
|
|
await stopStack();
|
|
};
|
|
}
|
|
|
|
export default globalSetup;
|