diff options
author | 2021-06-08 08:10:56 -0700 | |
---|---|---|
committer | 2021-06-08 11:10:56 -0400 | |
commit | 6bca7c83a7e2d62015f45f873b0f69f11b4d902b (patch) | |
tree | 5662630e51c6e6e743785d308785cff2e47568f0 /packages/create-astro/test/create-astro.test.js | |
parent | 9594447335b7fa15f82c0789f18a3fe02ec20d70 (diff) | |
download | astro-6bca7c83a7e2d62015f45f873b0f69f11b4d902b.tar.gz astro-6bca7c83a7e2d62015f45f873b0f69f11b4d902b.tar.zst astro-6bca7c83a7e2d62015f45f873b0f69f11b4d902b.zip |
redesign create-astro (#301)
* redesign create astro
* add changeset
* Use npm start
* Update the astro version
* Adds the changeset
Co-authored-by: Fred Schott <fks@Freds-MBP.attlocal.net>
Co-authored-by: Matthew Phillips <matthew@skypack.dev>
Diffstat (limited to 'packages/create-astro/test/create-astro.test.js')
-rw-r--r-- | packages/create-astro/test/create-astro.test.js | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/packages/create-astro/test/create-astro.test.js b/packages/create-astro/test/create-astro.test.js index aa9323012..b83d4f4a6 100644 --- a/packages/create-astro/test/create-astro.test.js +++ b/packages/create-astro/test/create-astro.test.js @@ -5,36 +5,40 @@ import { suite } from 'uvu'; import execa from 'execa'; import del from 'del'; import * as assert from 'uvu/assert'; +import {TEMPLATES} from '../dist/templates.js'; const CreateAstro = suite('npm init astro'); const cwd = fileURLToPath(path.dirname(import.meta.url)); -const templates = fs.readdirSync(path.join(cwd, '..', 'src', 'templates')); +const fixturesDir = path.join(cwd, 'fixtures'); CreateAstro.before(async () => { - const fixturesDir = path.join(cwd, 'fixtures'); await del(fixturesDir); await fs.promises.mkdir(fixturesDir); }); -for (const template of templates) { - CreateAstro(template, async () => { - const { stdout } = await execa('../../create-astro.js', [`./${template}`, '--template', template, '--skip-install'], { cwd: path.join(cwd, 'fixtures') }); +for (const {value: template} of TEMPLATES) { + // TODO: Unskip once repo is made public. Because the repo is private, the templates can't yet be downloaded. + CreateAstro.skip(template, async () => { + const testDirectory = path.join(fixturesDir, template); + const { stdout } = await execa('../../create-astro.mjs', [testDirectory, '--template', template, '--force-overwrite'], { cwd: path.join(cwd, 'fixtures') }); - // test: path should formatted as './{dirName}' + console.log(stdout); + // test: path should formatted as './{dirName}' assert.not.match(stdout, '././'); const DOES_HAVE = ['.gitignore', 'package.json', 'public', 'src']; - const DOES_NOT_HAVE = ['_gitignore', 'meta.json', 'node_modules', 'yarn.lock']; + const DOES_NOT_HAVE = ['meta.json', 'node_modules', 'yarn.lock']; // test: template contains essential files & folders for (const file of DOES_HAVE) { - assert.ok(fs.existsSync(path.join(cwd, template, file)), `has ${file}`); + console.log(path.join(testDirectory, file)); + assert.ok(fs.existsSync(path.join(testDirectory, file)), `has ${file}`); } // test: template DOES NOT contain files supposed to be stripped away for (const file of DOES_NOT_HAVE) { - assert.not.ok(fs.existsSync(path.join(cwd, template, file)), `does not have ${file}`); + assert.not.ok(fs.existsSync(path.join(testDirectory, file)), `does not have ${file}`); } }); } |