(
directory: string,
fn: Function,
{ skipDeploy = false } = {}
)
| 525 | } |
| 526 | |
| 527 | export function testFixtureStdio( |
| 528 | directory: string, |
| 529 | fn: Function, |
| 530 | { skipDeploy = false } = {} |
| 531 | ) { |
| 532 | return async () => { |
| 533 | const cwd = fixtureAbsolute(directory); |
| 534 | const token = await fetchCachedToken(); |
| 535 | let deploymentUrl: string; |
| 536 | |
| 537 | // Deploy fixture and link project |
| 538 | if (!skipDeploy) { |
| 539 | const projectJsonPath = join(cwd, '.vercel', 'project.json'); |
| 540 | await fs.remove(projectJsonPath); |
| 541 | const gitignore = join(cwd, '.gitignore'); |
| 542 | const hasGitignore = await fs.pathExists(gitignore); |
| 543 | |
| 544 | try { |
| 545 | const args = []; |
| 546 | |
| 547 | args.push('--token', token); |
| 548 | |
| 549 | if (process.env.VERCEL_TEAM_ID) { |
| 550 | args.push('--scope', process.env.VERCEL_TEAM_ID); |
| 551 | } |
| 552 | |
| 553 | args.push('deploy'); |
| 554 | |
| 555 | const buildEnvNames = [ |
| 556 | 'VERCEL_CLI_VERSION', |
| 557 | 'VERCEL_RUNTIME_PYTHON', |
| 558 | 'VERCEL_WORKERS_PYTHON', |
| 559 | ] as const; |
| 560 | for (const buildEnvName of buildEnvNames) { |
| 561 | const buildEnvValue = process.env[buildEnvName]; |
| 562 | if (buildEnvValue) { |
| 563 | args.push('--build-env', `${buildEnvName}=${buildEnvValue}`); |
| 564 | } |
| 565 | } |
| 566 | |
| 567 | args.push('--debug'); |
| 568 | args.push('--yes'); |
| 569 | |
| 570 | // Run `vc deploy` |
| 571 | const deployResult = await execa(binaryPath, args, { |
| 572 | cwd, |
| 573 | stdio: 'pipe', |
| 574 | reject: false, |
| 575 | }); |
| 576 | |
| 577 | const errorDetails = JSON.stringify({ |
| 578 | exitCode: deployResult.exitCode, |
| 579 | stdout: deployResult.stdout, |
| 580 | stderr: deployResult.stderr, |
| 581 | }); |
| 582 | |
| 583 | // Expect the deploy succeeded with exit of 0; |
| 584 | expect(deployResult.exitCode, errorDetails).toBe(0); |
no test coverage detected