diff options
Diffstat (limited to 'packages/create-astro/test')
-rw-r--r-- | packages/create-astro/test/astro-add-step.test.js | 7 | ||||
-rw-r--r-- | packages/create-astro/test/install-step.test.js | 11 | ||||
-rw-r--r-- | packages/create-astro/test/utils.js | 3 |
3 files changed, 16 insertions, 5 deletions
diff --git a/packages/create-astro/test/astro-add-step.test.js b/packages/create-astro/test/astro-add-step.test.js index b46d836cc..73d963ed0 100644 --- a/packages/create-astro/test/astro-add-step.test.js +++ b/packages/create-astro/test/astro-add-step.test.js @@ -23,13 +23,14 @@ describe('[create-astro] astro add', function () { }); it('should use "astro add" when user has installed dependencies', function () { - const { stdout, stdin } = setup([tempDir, '--dryrun']); + const { stdout, stdin } = setup([tempDir]); return promiseWithTimeout((resolve) => { const seen = new Set(); const installPrompt = PROMPT_MESSAGES.install('npm'); stdout.on('data', (chunk) => { if (!seen.has(PROMPT_MESSAGES.template) && chunk.includes(PROMPT_MESSAGES.template)) { seen.add(PROMPT_MESSAGES.template); + // respond with "enter key" stdin.write('\x0D'); } if (!seen.has(installPrompt) && chunk.includes(installPrompt)) { @@ -44,17 +45,19 @@ describe('[create-astro] astro add', function () { }); it('should use "npx astro@latest add" when use has NOT installed dependencies', function () { - const { stdout, stdin } = setup([tempDir, '--dryrun']); + const { stdout, stdin } = setup([tempDir]); return promiseWithTimeout((resolve) => { const seen = new Set(); const installPrompt = PROMPT_MESSAGES.install('npm'); stdout.on('data', (chunk) => { if (!seen.has(PROMPT_MESSAGES.template) && chunk.includes(PROMPT_MESSAGES.template)) { seen.add(PROMPT_MESSAGES.template); + // respond with "enter key" stdin.write('\x0D'); } if (!seen.has(installPrompt) && chunk.includes(installPrompt)) { seen.add(installPrompt); + // respond with "no, then enter key" stdin.write('n\x0D'); } if (chunk.includes(PROMPT_MESSAGES.astroAdd('npx astro@latest add --yes'))) { diff --git a/packages/create-astro/test/install-step.test.js b/packages/create-astro/test/install-step.test.js index fbd7f2249..d8219b520 100644 --- a/packages/create-astro/test/install-step.test.js +++ b/packages/create-astro/test/install-step.test.js @@ -21,13 +21,14 @@ describe('[create-astro] install', function () { }); it('should respect package manager in prompt', function () { - const { stdout, stdin } = setup([tempDir, '--dryrun']); + const { stdout, stdin } = setup([tempDir]); return promiseWithTimeout((resolve) => { const seen = new Set(); const installPrompt = PROMPT_MESSAGES.install(FAKE_PACKAGE_MANAGER); stdout.on('data', (chunk) => { if (!seen.has(PROMPT_MESSAGES.template) && chunk.includes(PROMPT_MESSAGES.template)) { seen.add(PROMPT_MESSAGES.template); + // respond with "enter key" stdin.write('\x0D'); } if (!seen.has(installPrompt) && chunk.includes(installPrompt)) { @@ -39,7 +40,7 @@ describe('[create-astro] install', function () { }); it('should respect package manager in next steps', function () { - const { stdout, stdin } = setup([tempDir, '--dryrun']); + const { stdout, stdin } = setup([tempDir]); return promiseWithTimeout((resolve) => { const seen = new Set(); const installPrompt = PROMPT_MESSAGES.install(FAKE_PACKAGE_MANAGER); @@ -47,14 +48,20 @@ describe('[create-astro] install', function () { stdout.on('data', (chunk) => { if (!seen.has(PROMPT_MESSAGES.template) && chunk.includes(PROMPT_MESSAGES.template)) { seen.add(PROMPT_MESSAGES.template); + // respond with "enter key" stdin.write('\x0D'); } if (!seen.has(installPrompt) && chunk.includes(installPrompt)) { seen.add(installPrompt); + // respond with "no, then enter key" stdin.write('n\x0D'); } if (!seen.has(astroAddPrompt) && chunk.includes(astroAddPrompt)) { seen.add(astroAddPrompt); + stdin.write('n\x0D'); + } + if (!seen.has(PROMPT_MESSAGES.git) && chunk.includes(PROMPT_MESSAGES.git)) { + seen.add(PROMPT_MESSAGES.git); stdin.write('\x0D'); } if (chunk.includes('banana dev')) { diff --git a/packages/create-astro/test/utils.js b/packages/create-astro/test/utils.js index 70ad32210..964ae6a20 100644 --- a/packages/create-astro/test/utils.js +++ b/packages/create-astro/test/utils.js @@ -29,10 +29,11 @@ export const PROMPT_MESSAGES = { install: (pkgManager) => `Would you like us to run "${pkgManager} install?"`, astroAdd: (astroAddCommand = 'npx astro@latest add --yes') => `Run "${astroAddCommand}?" This lets you optionally add component frameworks (ex. React), CSS frameworks (ex. Tailwind), and more.`, + git: 'Initialize a git repository?', }; export function setup(args = []) { - const { stdout, stdin } = execa('../create-astro.mjs', args, { cwd: testDir }); + const { stdout, stdin } = execa('../create-astro.mjs', [...args, '--dryrun'], { cwd: testDir }); return { stdin, stdout, |