Skip to content

Commit 1700831

Browse files
committed
test: use branch/alias deploys for e2e test suite to allow automatic cleanup
1 parent 5a2d6fa commit 1700831

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

tests/utils/create-e2e-fixture.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ async function deploySite(
268268
console.log(`🚀 Building and deploying site...`)
269269

270270
const outputFile = 'deploy-output.txt'
271-
let cmd = `npx netlify deploy --build --site ${siteId}`
271+
let cmd = `npx netlify deploy --build --site ${siteId} --alias next-e2e-tests`
272272

273273
if (packagePath) {
274274
cmd += ` --filter ${packagePath}`
@@ -278,11 +278,19 @@ async function deploySite(
278278
await execaCommand(cmd, { cwd: siteDir, all: true }).pipeAll?.(join(siteDir, outputFile))
279279
const output = await readFile(join(siteDir, outputFile), 'utf-8')
280280

281-
const [url] = new RegExp(/https:.+\.netlify\.app/gm).exec(output) || []
281+
const [url] =
282+
new RegExp(
283+
/https:\/\/app\.netlify\.com\/sites\/next-runtime-testing\/deploys\/^[0-9a-f]+/gm,
284+
).exec(output) || []
282285
if (!url) {
283286
throw new Error('Could not extract the URL from the build logs')
284287
}
285-
const [deployID] = new URL(url).host.split('--')
288+
289+
const deployID = url.split('/').pop()
290+
if (!deployID) {
291+
throw new Error('Could not extract DeployID from the build logs')
292+
}
293+
286294
return { url, deployID, logs: output }
287295
}
288296

0 commit comments

Comments
 (0)