Skip to content

Commit f0e2da0

Browse files
committed
test: use branch/alias deploys for vercel tests
1 parent 81042da commit f0e2da0

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

tests/netlify-deploy.ts

+13-11
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,11 @@ export class NextDeployInstance extends NextInstance {
129129
const deployTitle = process.env.GITHUB_SHA
130130
? `${testName} - ${process.env.GITHUB_SHA}`
131131
: testName
132+
const deployAlias = 'vercel-next-e2e'
132133

133134
const deployRes = await execa(
134135
'npx',
135-
['netlify', 'deploy', '--build', '--message', deployTitle ?? ''],
136+
['netlify', 'deploy', '--build', '--message', deployTitle ?? '', '--alias', deployAlias],
136137
{
137138
cwd: this.testDir,
138139
reject: false,
@@ -146,22 +147,23 @@ export class NextDeployInstance extends NextInstance {
146147
}
147148

148149
try {
149-
const [url] = new RegExp(/https:.+\.netlify\.app/gm).exec(deployRes.stdout) || []
150-
if (!url) {
151-
throw new Error('Could not extract the URL from the build logs')
150+
const deployUrlRegex = new RegExp(
151+
/https:\/\/app\.netlify\.com\/sites\/(?<siteName>.+)\/deploys\/(?<deployID>[0-9a-f]+)/gm,
152+
).exec(deployRes.stdout)
153+
const [buildLogsUrl] = deployUrlRegex || []
154+
const { deployID, siteName } = deployUrlRegex?.groups || {}
155+
156+
if (!deployID) {
157+
throw new Error('Could not extract DeployID from the build logs')
152158
}
153-
const [deployID] = new URL(url).host.split('--')
154-
this._url = url
159+
160+
this._url = `https://${deployID}--${siteName}.netlify.app/`
155161
this._parsedUrl = new URL(this._url)
156162
this._deployId = deployID
157163
this._shouldDeleteDeploy = !process.env.NEXT_TEST_SKIP_CLEANUP
158164
this._cliOutput = deployRes.stdout + deployRes.stderr
159-
require('console').log(`Deployment URL: ${this._url}`)
160165

161-
const [buildLogsUrl] =
162-
new RegExp(/https:\/\/app\.netlify\.com\/sites\/.+\/deploys\/[0-9a-f]+/gm).exec(
163-
deployRes.stdout,
164-
) || []
166+
require('console').log(`Deployment URL: ${this._url}`)
165167
if (buildLogsUrl) {
166168
require('console').log(`Logs: ${buildLogsUrl}`)
167169
}

0 commit comments

Comments
 (0)