Unverified Commit 92cccfb4 authored by Steven's avatar Steven Committed by GitHub

chore(test): add logs for create-next-app tests (#56957)

This will help us debug why these tests sometimes flake by logging which command was running last.
parent 66597be8
......@@ -23,7 +23,13 @@ const env = { ...process.env, COREPACK_ENABLE_STRICT: '0' }
const run = (args: string[], options: execa.Options) => {
const conf = new Conf({ projectName: 'create-next-app' })
conf.clear()
return execa('node', [cli].concat(args), options)
console.log(`Running "create-next-app ${args.join(' ')}"`)
return execa('node', [cli].concat(args), { ...options, stdio: 'inherit' })
}
const command = (cmd: string, args: string[]) => {
console.log(`Running command "${cmd} ${args.join(' ')}"`)
return execa(cmd, args, { stdio: 'inherit' })
}
it('should use npm as the package manager on supplying --use-npm', async () => {
......@@ -120,13 +126,13 @@ it('should use Yarn as the package manager on supplying --use-yarn', async () =>
it('should use Yarn as the package manager on supplying --use-yarn with example', async () => {
try {
await execa('yarn', ['--version'])
await command('yarn', ['--version'])
} catch (_) {
// install yarn if not available
try {
await execa('corepack', ['prepare', '--activate', 'yarn@1.22.19'])
await command('corepack', ['prepare', '--activate', 'yarn@1.22.19'])
} catch (_) {
await execa('npm', ['i', '-g', 'yarn'])
await command('npm', ['i', '-g', 'yarn'])
}
}
......@@ -198,13 +204,13 @@ it('should use pnpm as the package manager on supplying --use-pnpm', async () =>
it('should use pnpm as the package manager on supplying --use-pnpm with example', async () => {
try {
await execa('pnpm', ['--version'])
await command('pnpm', ['--version'])
} catch (_) {
// install pnpm if not available
try {
await execa('corepack', ['prepare', '--activate', 'pnpm@latest'])
await command('corepack', ['prepare', '--activate', 'pnpm@latest'])
} catch (_) {
await execa('npm', ['i', '-g', 'pnpm'])
await command('npm', ['i', '-g', 'pnpm'])
}
}
......@@ -276,10 +282,10 @@ it('should use Bun as the package manager on supplying --use-bun', async () => {
it('should use Bun as the package manager on supplying --use-bun with example', async () => {
try {
await execa('bun', ['--version'])
await command('bun', ['--version'])
} catch (_) {
// install Bun if not available
await execa('npm', ['i', '-g', 'bun'])
await command('npm', ['i', '-g', 'bun'])
}
await useTempDir(async (cwd) => {
......@@ -375,13 +381,13 @@ it('should infer npm as the package manager with example', async () => {
it('should infer yarn as the package manager', async () => {
try {
await execa('yarn', ['--version'])
await command('yarn', ['--version'])
} catch (_) {
// install yarn if not available
try {
await execa('corepack', ['prepare', '--activate', 'yarn@1.22.19'])
await command('corepack', ['prepare', '--activate', 'yarn@1.22.19'])
} catch (_) {
await execa('npm', ['i', '-g', 'yarn'])
await command('npm', ['i', '-g', 'yarn'])
}
}
......@@ -419,13 +425,13 @@ it('should infer yarn as the package manager', async () => {
it('should infer yarn as the package manager with example', async () => {
try {
await execa('yarn', ['--version'])
await command('yarn', ['--version'])
} catch (_) {
// install yarn if not available
try {
await execa('corepack', ['prepare', '--activate', 'yarn@1.22.19'])
await command('corepack', ['prepare', '--activate', 'yarn@1.22.19'])
} catch (_) {
await execa('npm', ['i', '-g', 'yarn'])
await command('npm', ['i', '-g', 'yarn'])
}
}
......@@ -458,13 +464,13 @@ it('should infer yarn as the package manager with example', async () => {
it('should infer pnpm as the package manager', async () => {
try {
await execa('pnpm', ['--version'])
await command('pnpm', ['--version'])
} catch (_) {
// install pnpm if not available
try {
await execa('corepack', ['prepare', '--activate', 'pnpm@latest'])
await command('corepack', ['prepare', '--activate', 'pnpm@latest'])
} catch (_) {
await execa('npm', ['i', '-g', 'pnpm'])
await command('npm', ['i', '-g', 'pnpm'])
}
}
......@@ -502,13 +508,13 @@ it('should infer pnpm as the package manager', async () => {
it('should infer pnpm as the package manager with example', async () => {
try {
await execa('pnpm', ['--version'])
await command('pnpm', ['--version'])
} catch (_) {
// install pnpm if not available
try {
await execa('corepack', ['prepare', '--activate', 'pnpm@latest'])
await command('corepack', ['prepare', '--activate', 'pnpm@latest'])
} catch (_) {
await execa('npm', ['i', '-g', 'pnpm'])
await command('npm', ['i', '-g', 'pnpm'])
}
}
......@@ -541,10 +547,10 @@ it('should infer pnpm as the package manager with example', async () => {
it('should infer Bun as the package manager', async () => {
try {
await execa('bun', ['--version'])
await command('bun', ['--version'])
} catch (_) {
// install Bun if not available
await execa('npm', ['i', '-g', 'bun'])
await command('npm', ['i', '-g', 'bun'])
}
await useTempDir(async (cwd) => {
......@@ -581,10 +587,10 @@ it('should infer Bun as the package manager', async () => {
it('should infer Bun as the package manager with example', async () => {
try {
await execa('bun', ['--version'])
await command('bun', ['--version'])
} catch (_) {
// install Bun if not available
await execa('npm', ['i', '-g', 'bun'])
await command('npm', ['i', '-g', 'bun'])
}
await useTempDir(async (cwd) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment