Skip to content

Commit a8d8fca

Browse files
committed
chore: allow e2e fixtures to override site id
1 parent 287177a commit a8d8fca

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

tests/utils/create-e2e-fixture.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import { cpus } from 'os'
1111
import pLimit from 'p-limit'
1212
import { setNextVersionInFixture } from './next-version-helpers.mjs'
1313

14-
// This is the netlify testing application
15-
export const SITE_ID = process.env.NETLIFY_SITE_ID ?? 'ee859ce9-44a7-46be-830b-ead85e445e53'
14+
// https://app.netlify.com/sites/next-runtime-testing
15+
const DEFAULT_SITE_ID = 'ee859ce9-44a7-46be-830b-ead85e445e53'
16+
export const SITE_ID = process.env.NETLIFY_SITE_ID ?? DEFAULT_SITE_ID
1617
const NEXT_VERSION = process.env.NEXT_VERSION || 'latest'
1718

1819
export interface DeployResult {
@@ -39,6 +40,10 @@ interface E2EConfig {
3940
* Some fixtures might pin to non-latest CLI versions. This is used to verify the used CLI version matches expected one
4041
*/
4142
expectedCliVersion?: string
43+
/**
44+
* Site ID to deploy to. Defaults to the `NETLIFY_SITE_ID` environment variable or a default site.
45+
*/
46+
siteId?: string
4247
}
4348

4449
/**
@@ -258,12 +263,12 @@ async function verifyFixture(isolatedFixtureRoot: string, { expectedCliVersion }
258263

259264
async function deploySite(
260265
isolatedFixtureRoot: string,
261-
{ packagePath, cwd = '' }: E2EConfig,
266+
{ packagePath, cwd = '', siteId = SITE_ID }: E2EConfig,
262267
): Promise<DeployResult> {
263268
console.log(`🚀 Building and deploying site...`)
264269

265270
const outputFile = 'deploy-output.txt'
266-
let cmd = `npx ntl deploy --build --site ${SITE_ID}`
271+
let cmd = `npx ntl deploy --build --site ${siteId}`
267272

268273
if (packagePath) {
269274
cmd += ` --filter ${packagePath}`
@@ -273,7 +278,7 @@ async function deploySite(
273278
await execaCommand(cmd, { cwd: siteDir, all: true }).pipeAll?.(join(siteDir, outputFile))
274279
const output = await readFile(join(siteDir, outputFile), 'utf-8')
275280

276-
const [url] = new RegExp(/https:.+runtime-testing\.netlify\.app/gm).exec(output) || []
281+
const [url] = new RegExp(/https:.+\.netlify\.app/gm).exec(output) || []
277282
if (!url) {
278283
throw new Error('Could not extract the URL from the build logs')
279284
}

0 commit comments

Comments
 (0)