MCPcopy Create free account
hub / github.com/vercel/vercel / vcDevAndFetchSystemVars

Function vcDevAndFetchSystemVars

packages/cli/test/integration-1.test.ts:749–786  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

747 }
748
749 async function vcDevAndFetchSystemVars() {
750 const vc = execCli(binaryPath, ['dev'], {
751 cwd: target,
752 });
753
754 const localhost = await getLocalhost(vc);
755 const apiUrl = `${localhost[0]}/api/get-env`;
756 const apiRes = await nodeFetch(apiUrl);
757
758 const localhostNoProtocol = localhost[0].slice('http://'.length);
759
760 const apiJson = await apiRes.json();
761 // environment variables are not set in dev
762 expect(apiJson['VERCEL']).toBeUndefined();
763 expect(apiJson['VERCEL_ENV']).toBeUndefined();
764 expect(apiJson['VERCEL_GIT_PROVIDER']).toBeUndefined();
765 expect(apiJson['VERCEL_GIT_REPO_SLUG']).toBeUndefined();
766 // except for these because vc dev
767 expect(apiJson['VERCEL_URL']).toBe(localhostNoProtocol);
768 expect(apiJson['VERCEL_REGION']).toBe('dev1');
769
770 const homeUrl = localhost[0];
771 const homeRes = await nodeFetch(homeUrl);
772 const homeJson = await homeRes.json();
773 expect(homeJson['VERCEL']).toBe('1');
774 expect(homeJson['VERCEL_URL']).toBe(localhostNoProtocol);
775 expect(homeJson['VERCEL_ENV']).toBe('development');
776 expect(homeJson['VERCEL_REGION']).toBeUndefined();
777 expect(homeJson['VERCEL_GIT_PROVIDER']).toBeUndefined();
778 expect(homeJson['VERCEL_GIT_REPO_SLUG']).toBeUndefined();
779
780 // sleep before kill, otherwise the dev process doesn't clean up and exit properly
781 await sleep(100);
782 vc.kill('SIGTERM', { forceKillAfterTimeout: 5000 });
783
784 const { exitCode, stdout, stderr } = await vc;
785 expect(exitCode, formatOutput({ stdout, stderr })).toBe(0);
786 }
787
788 async function vcEnvRemove() {
789 const vc = execCli(binaryPath, ['env', 'rm', '-y'], {

Callers 1

Calls 6

execCliFunction · 0.90
getLocalhostFunction · 0.85
killMethod · 0.80
jsonMethod · 0.65
sleepFunction · 0.50
formatOutputFunction · 0.50

Tested by

no test coverage detected