diff options
author | 2021-05-24 16:18:56 -0600 | |
---|---|---|
committer | 2021-05-24 16:18:56 -0600 | |
commit | f5ecbee192ef24f52f78ffad0ba7bce686bd45c7 (patch) | |
tree | e841a1804768e8e91e4b455bc0bd4f6f4fa93597 /packages/create-astro/test/create-astro.test.js | |
parent | 860a84d4f4b2c8ea071385ac08ffcfb12c19d573 (diff) | |
download | astro-f5ecbee192ef24f52f78ffad0ba7bce686bd45c7.tar.gz astro-f5ecbee192ef24f52f78ffad0ba7bce686bd45c7.tar.zst astro-f5ecbee192ef24f52f78ffad0ba7bce686bd45c7.zip |
Add test for npm init astro (#238)
* Add test for npm init astro
* Use Lerna to run test
Diffstat (limited to 'packages/create-astro/test/create-astro.test.js')
-rw-r--r-- | packages/create-astro/test/create-astro.test.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/packages/create-astro/test/create-astro.test.js b/packages/create-astro/test/create-astro.test.js new file mode 100644 index 000000000..5fb556ef3 --- /dev/null +++ b/packages/create-astro/test/create-astro.test.js @@ -0,0 +1,39 @@ +import fs from 'fs'; +import path from 'path'; +import { fileURLToPath } from 'url'; +import { suite } from 'uvu'; +import execa from 'execa'; +import del from 'del'; +import * as assert from 'uvu/assert'; + +const CreateAstro = suite('npm init astro'); + +const cwd = fileURLToPath(new URL('./fixtures/', import.meta.url)); + +const templates = ['blank', 'starter']; + +CreateAstro.before(async () => { + await del(cwd); + await fs.promises.mkdir(cwd); +}); + +for (const template of templates) { + CreateAstro(template, async () => { + await execa('../../create-astro.js', [template, '--template', template], { cwd }); + + const DOES_HAVE = ['.gitignore', 'package.json', 'public', 'src']; + const DOES_NOT_HAVE = ['_gitignore', 'meta.json']; + + // test: template contains essential files & folders + for (const file of DOES_HAVE) { + assert.ok(fs.existsSync(path.join(cwd, template, 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, `does not have ${file}`))); + } + }); +} + +CreateAstro.run(); |