summaryrefslogtreecommitdiff
path: root/packages/create-astro/test
diff options
context:
space:
mode:
Diffstat (limited to 'packages/create-astro/test')
-rw-r--r--packages/create-astro/test/astro-add-step.test.js69
-rw-r--r--packages/create-astro/test/install-step.test.js5
-rw-r--r--packages/create-astro/test/utils.js8
3 files changed, 3 insertions, 79 deletions
diff --git a/packages/create-astro/test/astro-add-step.test.js b/packages/create-astro/test/astro-add-step.test.js
deleted file mode 100644
index 73d963ed0..000000000
--- a/packages/create-astro/test/astro-add-step.test.js
+++ /dev/null
@@ -1,69 +0,0 @@
-import { setup, promiseWithTimeout, timeout, PROMPT_MESSAGES } from './utils.js';
-import { sep } from 'path';
-import fs from 'fs';
-import os from 'os';
-
-// reset package manager in process.env
-// prevents test issues when running with pnpm
-const FAKE_PACKAGE_MANAGER = 'npm';
-let initialEnvValue = null;
-
-describe('[create-astro] astro add', function () {
- this.timeout(timeout);
- let tempDir = '';
- beforeEach(async () => {
- tempDir = await fs.promises.mkdtemp(`${os.tmpdir()}${sep}`);
- });
- this.beforeAll(() => {
- initialEnvValue = process.env.npm_config_user_agent;
- process.env.npm_config_user_agent = FAKE_PACKAGE_MANAGER;
- });
- this.afterAll(() => {
- process.env.npm_config_user_agent = initialEnvValue;
- });
-
- it('should use "astro add" when user has installed dependencies', function () {
- 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);
- stdin.write('\x0D');
- }
- if (chunk.includes(PROMPT_MESSAGES.astroAdd('astro add --yes'))) {
- resolve();
- }
- });
- });
- });
-
- it('should use "npx astro@latest add" when use has NOT installed dependencies', function () {
- 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'))) {
- resolve();
- }
- });
- });
- });
-});
diff --git a/packages/create-astro/test/install-step.test.js b/packages/create-astro/test/install-step.test.js
index d8219b520..3f1dea4a9 100644
--- a/packages/create-astro/test/install-step.test.js
+++ b/packages/create-astro/test/install-step.test.js
@@ -44,7 +44,6 @@ describe('[create-astro] install', function () {
return promiseWithTimeout((resolve) => {
const seen = new Set();
const installPrompt = PROMPT_MESSAGES.install(FAKE_PACKAGE_MANAGER);
- const astroAddPrompt = PROMPT_MESSAGES.astroAdd();
stdout.on('data', (chunk) => {
if (!seen.has(PROMPT_MESSAGES.template) && chunk.includes(PROMPT_MESSAGES.template)) {
seen.add(PROMPT_MESSAGES.template);
@@ -56,10 +55,6 @@ describe('[create-astro] install', function () {
// 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');
diff --git a/packages/create-astro/test/utils.js b/packages/create-astro/test/utils.js
index 964ae6a20..9d227f6b5 100644
--- a/packages/create-astro/test/utils.js
+++ b/packages/create-astro/test/utils.js
@@ -24,12 +24,10 @@ export function promiseWithTimeout(testFn) {
}
export const PROMPT_MESSAGES = {
- directory: 'Where would you like to create your app?',
- template: 'Which app template would you like to use?',
+ directory: 'Where would you like to create your new project?',
+ template: 'Which template would you like to use?',
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?',
+ git: 'Initialize a new git repository?',
};
export function setup(args = []) {