diff --git a/test/helpers.ts b/test/helpers.ts index 0ea1e5939b..6a6719282f 100644 --- a/test/helpers.ts +++ b/test/helpers.ts @@ -1,6 +1,7 @@ import type { Locator, Page } from '@playwright/test' import { expect } from '@playwright/test' +import shelljs from 'shelljs' import wait from '../packages/payload/src/utilities/wait' import { devUser } from './credentials' @@ -133,3 +134,18 @@ export function initPageConsoleErrorCatch(page: Page) { } }) } + +export function describeIfInCIOrHasLocalstack(): jest.Describe { + if (process.env.CI) { + return describe + } + + // Check that localstack is running + const { code } = shelljs.exec(`docker ps | grep localstack`) + + if (code !== 0) { + return describe.skip + } + + return describe +} diff --git a/test/plugin-cloud-storage/int.spec.ts b/test/plugin-cloud-storage/int.spec.ts index 8db2cede3d..be9707831b 100644 --- a/test/plugin-cloud-storage/int.spec.ts +++ b/test/plugin-cloud-storage/int.spec.ts @@ -1,23 +1,16 @@ +/* eslint-disable jest/require-top-level-describe */ import * as AWS from '@aws-sdk/client-s3' import path from 'path' -import shelljs from 'shelljs' import payload from '../../packages/payload/src' +import { describeIfInCIOrHasLocalstack } from '../helpers' import { initPayloadTest } from '../helpers/configHelpers' const TEST_BUCKET = 'payload-bucket' let client: AWS.S3Client -describe('plugin-cloud-storage', () => { +describeIfInCIOrHasLocalstack()('plugin-cloud-storage', () => { beforeAll(async () => { - // Check that localstack is running - const { code } = shelljs.exec(`docker ps | grep localstack`) - if (code !== 0) { - throw new Error( - `Localstack is not running. Please run "pnpm docker:start" before running this test.`, - ) - } - client = new AWS.S3({ endpoint: 'http://localhost:4566', region: 'us-east-1',