Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Oct 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 31 additions & 25 deletions test/integration/create-next-app/package-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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'])
}
}

Expand Down Expand Up @@ -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'])
}
}

Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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'])
}
}

Expand Down Expand Up @@ -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'])
}
}

Expand Down Expand Up @@ -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'])
}
}

Expand Down Expand Up @@ -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'])
}
}

Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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) => {
Expand Down