chore: adds spawn process to playwright tests as well

This commit is contained in:
James
2024-03-09 14:53:53 -05:00
parent 94aa309910
commit bdf02bebaa

View File

@@ -1,3 +1,4 @@
import { spawn } from 'child_process'
import getPort from 'get-port'
import { nextDev } from 'next/dist/cli/next-dev.js'
import path from 'path'
@@ -19,16 +20,41 @@ export async function initPayloadE2E({ dirname }: Args): Promise<Result> {
process.env.PAYLOAD_DROP_DATABASE = 'true'
process.env.PORT = String(port)
//process.env.NODE_ENV = 'test'
//process.env.APP_ENV = 'test'
//process.env.__NEXT_TEST_MODE = 'jest'
// @ts-expect-error
process.env.NODE_ENV = 'test'
nextDev({
_: [path.resolve(dirname, '../../')],
'--port': port,
// Turbo doesn't seem to be reading
// our tsconfig paths, commented out for now
// '--turbo': '1',
})
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 }
}