(
directory: string,
opts: Options<null> & { skipNpmInstall?: boolean } = {},
args: string[] = []
)
| 399 | } |
| 400 | |
| 401 | export 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 | }); |
no test coverage detected