Skip to content

Commit c5dd3a1

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

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tests/utils/create-e2e-fixture.ts

+7-4
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}`
@@ -277,12 +277,15 @@ async function deploySite(
277277
const siteDir = join(isolatedFixtureRoot, cwd)
278278
await execaCommand(cmd, { cwd: siteDir, all: true }).pipeAll?.(join(siteDir, outputFile))
279279
const output = await readFile(join(siteDir, outputFile), 'utf-8')
280-
281-
const [url] = new RegExp(/https:.+\.netlify\.app/gm).exec(output) || []
280+
const [url] = new RegExp(/https:\/\/app\.netlify\.com\/sites\/next-runtime-testing\/deploys\/^[0-9a-f]+/gm).exec(output) || []
282281
if (!url) {
283282
throw new Error('Could not extract the URL from the build logs')
284283
}
285-
const [deployID] = new URL(url).host.split('--')
284+
285+
const deployID = url.split('/').pop()
286+
if (!deployID) {
287+
throw new Error('Could not extract DeployID from the build logs')
288+
}
286289
return { url, deployID, logs: output }
287290
}
288291

0 commit comments

Comments
 (0)