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

Function testFixture

packages/cli/test/dev/utils.ts:401–525  ·  view source on GitHub ↗
(
  directory: string,
  opts: Options<null> & { skipNpmInstall?: boolean } = {},
  args: string[] = []
)

Source from the content-addressed store, hash-verified

399}
400
401export async function testFixture(
402 directory: string,
403 opts: Options<null> & { skipNpmInstall?: boolean } = {},
404 args: string[] = []
405) {
406 const { skipNpmInstall, ...execaOpts } = opts;
407 if (!skipNpmInstall) {
408 await runNpmInstall(directory);
409 }
410
411 const token = await fetchCachedToken();
412
413 console.log(
414 `testFixture() ${binaryPath} dev ${directory} -t ***${
415 process.env.VERCEL_TEAM_ID ? ' --scope ***' : ''
416 } -l ${port} ${args.join(' ')}`
417 );
418 const dev = execa(
419 binaryPath,
420 [
421 'dev',
422 directory,
423 '-t',
424 token,
425 ...(process.env.VERCEL_TEAM_ID
426 ? ['--scope', process.env.VERCEL_TEAM_ID]
427 : []),
428 '-l',
429 String(port),
430 ...args,
431 ],
432 {
433 reject: false,
434 shell: true,
435 stdio: 'pipe',
436 ...execaOpts,
437 env: { ...execaOpts.env, __VERCEL_SKIP_DEV_CMD: '1' },
438 }
439 );
440
441 let stdout = '';
442 let stderr = '';
443 const readyResolver = createResolver();
444 const exitResolver = createResolver();
445
446 if (!dev.stdout) {
447 throw new Error('`vc dev` process missing "stdout".');
448 }
449 if (!dev.stderr) {
450 throw new Error('`vc dev` process missing "stderr".');
451 }
452
453 dev.stdout.setEncoding('utf8');
454 dev.stderr.setEncoding('utf8');
455
456 dev.stdout.on('data', data => {
457 stdout += data;
458 });

Calls 13

fetchCachedTokenFunction · 0.90
execaFunction · 0.85
createResolverFunction · 0.85
psFunction · 0.85
printOutputFunction · 0.85
nukeProcessTreeFunction · 0.85
errorMethod · 0.80
runNpmInstallFunction · 0.70
stripAnsiFunction · 0.50
logMethod · 0.45
joinMethod · 0.45
resolveMethod · 0.45

Tested by

no test coverage detected