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' } ...@@ -23,7 +23,13 @@ const env = { ...process.env, COREPACK_ENABLE_STRICT: '0' }
const run = (args: string[], options: execa.Options) => { const run = (args: string[], options: execa.Options) => {
const conf = new Conf({ projectName: 'create-next-app' }) const conf = new Conf({ projectName: 'create-next-app' })
conf.clear() 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 () => { 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 () => ...@@ -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 () => { it('should use Yarn as the package manager on supplying --use-yarn with example', async () => {
try { try {
await execa('yarn', ['--version']) await command('yarn', ['--version'])
} catch (_) { } catch (_) {
// install yarn if not available // install yarn if not available
try { try {
await execa('corepack', ['prepare', '--activate', 'yarn@1.22.19']) await command('corepack', ['prepare', '--activate', 'yarn@1.22.19'])
} catch (_) { } 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 () => ...@@ -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 () => { it('should use pnpm as the package manager on supplying --use-pnpm with example', async () => {
try { try {
await execa('pnpm', ['--version']) await command('pnpm', ['--version'])
} catch (_) { } catch (_) {
// install pnpm if not available // install pnpm if not available
try { try {
await execa('corepack', ['prepare', '--activate', 'pnpm@latest']) await command('corepack', ['prepare', '--activate', 'pnpm@latest'])
} catch (_) { } 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 () => { ...@@ -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 () => { it('should use Bun as the package manager on supplying --use-bun with example', async () => {
try { try {
await execa('bun', ['--version']) await command('bun', ['--version'])
} catch (_) { } catch (_) {
// install Bun if not available // install Bun if not available
await execa('npm', ['i', '-g', 'bun']) await command('npm', ['i', '-g', 'bun'])
} }
await useTempDir(async (cwd) => { await useTempDir(async (cwd) => {
...@@ -375,13 +381,13 @@ it('should infer npm as the package manager with example', async () => { ...@@ -375,13 +381,13 @@ it('should infer npm as the package manager with example', async () => {
it('should infer yarn as the package manager', async () => { it('should infer yarn as the package manager', async () => {
try { try {
await execa('yarn', ['--version']) await command('yarn', ['--version'])
} catch (_) { } catch (_) {
// install yarn if not available // install yarn if not available
try { try {
await execa('corepack', ['prepare', '--activate', 'yarn@1.22.19']) await command('corepack', ['prepare', '--activate', 'yarn@1.22.19'])
} catch (_) { } 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 () => { ...@@ -419,13 +425,13 @@ it('should infer yarn as the package manager', async () => {
it('should infer yarn as the package manager with example', async () => { it('should infer yarn as the package manager with example', async () => {
try { try {
await execa('yarn', ['--version']) await command('yarn', ['--version'])
} catch (_) { } catch (_) {
// install yarn if not available // install yarn if not available
try { try {
await execa('corepack', ['prepare', '--activate', 'yarn@1.22.19']) await command('corepack', ['prepare', '--activate', 'yarn@1.22.19'])
} catch (_) { } 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 () => { ...@@ -458,13 +464,13 @@ it('should infer yarn as the package manager with example', async () => {
it('should infer pnpm as the package manager', async () => { it('should infer pnpm as the package manager', async () => {
try { try {
await execa('pnpm', ['--version']) await command('pnpm', ['--version'])
} catch (_) { } catch (_) {
// install pnpm if not available // install pnpm if not available
try { try {
await execa('corepack', ['prepare', '--activate', 'pnpm@latest']) await command('corepack', ['prepare', '--activate', 'pnpm@latest'])
} catch (_) { } 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 () => { ...@@ -502,13 +508,13 @@ it('should infer pnpm as the package manager', async () => {
it('should infer pnpm as the package manager with example', async () => { it('should infer pnpm as the package manager with example', async () => {
try { try {
await execa('pnpm', ['--version']) await command('pnpm', ['--version'])
} catch (_) { } catch (_) {
// install pnpm if not available // install pnpm if not available
try { try {
await execa('corepack', ['prepare', '--activate', 'pnpm@latest']) await command('corepack', ['prepare', '--activate', 'pnpm@latest'])
} catch (_) { } 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 () => { ...@@ -541,10 +547,10 @@ it('should infer pnpm as the package manager with example', async () => {
it('should infer Bun as the package manager', async () => { it('should infer Bun as the package manager', async () => {
try { try {
await execa('bun', ['--version']) await command('bun', ['--version'])
} catch (_) { } catch (_) {
// install Bun if not available // install Bun if not available
await execa('npm', ['i', '-g', 'bun']) await command('npm', ['i', '-g', 'bun'])
} }
await useTempDir(async (cwd) => { await useTempDir(async (cwd) => {
...@@ -581,10 +587,10 @@ it('should infer Bun as the package manager', async () => { ...@@ -581,10 +587,10 @@ it('should infer Bun as the package manager', async () => {
it('should infer Bun as the package manager with example', async () => { it('should infer Bun as the package manager with example', async () => {
try { try {
await execa('bun', ['--version']) await command('bun', ['--version'])
} catch (_) { } catch (_) {
// install Bun if not available // install Bun if not available
await execa('npm', ['i', '-g', 'bun']) await command('npm', ['i', '-g', 'bun'])
} }
await useTempDir(async (cwd) => { 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