Skip to content

Commit cb97614

Browse files
authored
chore: allow e2e port to be defined by env vars (#16285)
Port number is currently hardcoded to 3000, this makes it so it defaults back to 3000 but you can override it via env vars. Helps when running lots of e2es in parallel with various agents by providing predictability.
1 parent 8de32a2 commit cb97614

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

test/__helpers/shared/initPayloadE2ENoConfig.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ export async function initPayloadE2ENoConfig<T extends GeneratedTypes<T>>({
2626
}: Args): Promise<Result<T>> {
2727
const testSuiteName = path.basename(dirname)
2828

29-
const port = 3000
29+
// Default to 3000 if PORT is not set, but allow it to be overridden by the environment variable
30+
const defaultPort = 3000
31+
32+
const port = process.env.PORT ? Number(process.env.PORT) : defaultPort
3033
process.env.PORT = String(port)
3134
process.env.PAYLOAD_CI_DEPENDENCY_CHECKER = 'true'
3235

@@ -51,7 +54,7 @@ export async function initPayloadE2ENoConfig<T extends GeneratedTypes<T>>({
5154
if (code === 0) {
5255
res()
5356
}
54-
rej()
57+
rej(new Error('closed with code ' + code))
5558
})
5659
})
5760
}

0 commit comments

Comments
 (0)