chore: _community e2e
This commit is contained in:
@@ -1,19 +1,24 @@
|
||||
import { spawn } from 'child_process'
|
||||
import getPort from 'get-port'
|
||||
import { nextDev } from 'next/dist/cli/next-dev.js'
|
||||
import path from 'path'
|
||||
|
||||
import type { SanitizedConfig } from '../../packages/payload/src/config/types.js'
|
||||
import type { Payload } from '../../packages/payload/src/index.js'
|
||||
|
||||
import { getPayload } from '../../packages/payload/src/index.js'
|
||||
import wait from '../../packages/payload/src/utilities/wait.js'
|
||||
|
||||
type Args = {
|
||||
config: Promise<SanitizedConfig>
|
||||
dirname: string
|
||||
}
|
||||
|
||||
type Result = {
|
||||
payload: Payload
|
||||
serverURL: string
|
||||
}
|
||||
|
||||
export async function initPayloadE2E({ dirname }: Args): Promise<Result> {
|
||||
export async function initPayloadE2E({ config, dirname }: Args): Promise<Result> {
|
||||
const port = await getPort()
|
||||
const serverURL = `http://localhost:${port}`
|
||||
process.env.NODE_OPTIONS = '--no-deprecation'
|
||||
@@ -21,6 +26,8 @@ export async function initPayloadE2E({ dirname }: Args): Promise<Result> {
|
||||
process.env.PAYLOAD_DROP_DATABASE = 'true'
|
||||
process.env.PORT = String(port)
|
||||
|
||||
const payload = await getPayload({ config })
|
||||
|
||||
// @ts-expect-error
|
||||
process.env.NODE_ENV = 'test'
|
||||
|
||||
@@ -33,29 +40,5 @@ export async function initPayloadE2E({ dirname }: Args): Promise<Result> {
|
||||
})
|
||||
|
||||
await wait(3000)
|
||||
return { serverURL }
|
||||
}
|
||||
|
||||
export async function initPayloadSpawn({ dirname }: Args): Promise<Result> {
|
||||
const port = await getPort()
|
||||
const serverURL = `http://localhost:${port}`
|
||||
|
||||
// Tried using a child process to get
|
||||
// turbopack to pick up our tsconfig aliases
|
||||
// but this didn't make a difference.
|
||||
// Keeping it here so we can continue to try.
|
||||
spawn('pnpm', ['dev', '--turbo'], {
|
||||
cwd: path.resolve(dirname, '../../'),
|
||||
env: {
|
||||
...process.env,
|
||||
NODE_ENV: 'test',
|
||||
PORT: String(port),
|
||||
PAYLOAD_CONFIG_PATH: path.resolve(dirname, '../../config.js'),
|
||||
PAYLOAD_DROP_DATABASE: 'true',
|
||||
},
|
||||
})
|
||||
|
||||
await wait(3000)
|
||||
|
||||
return { serverURL }
|
||||
return { payload, serverURL }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user