test: conditionally run plugin-cloud-storage

This commit is contained in:
Elliot DeNolf
2023-11-28 16:54:34 -05:00
parent f0f1dbdcb0
commit 8f4d0da4e0
2 changed files with 19 additions and 10 deletions

View File

@@ -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
}

View File

@@ -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',