Skip to content

Commit

Permalink
chore: cli create test
Browse files Browse the repository at this point in the history
  • Loading branch information
shellscape committed Oct 29, 2024
1 parent 496d5e5 commit 00fcad0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.moon/cache
.eslintcache
.rendered
.test
node_modules
dist
.DS_Store
Expand Down
3 changes: 3 additions & 0 deletions test/cli/.snapshots/create.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`cli > esbuild plugins 1`] = `Promise {}`;
28 changes: 28 additions & 0 deletions test/cli/create.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { readFile } from 'node:fs/promises';
import { join } from 'node:path';

import { execa } from 'execa';
import { describe, expect, test } from 'vitest';
import strip from 'strip-ansi';

process.chdir(__dirname);

describe('cli', async () => {
test('esbuild plugins', async () => {
const { stdout } = await execa({
cwd: __dirname,
shell: true
// Note: For some reason `pnpm exec` is fucking with our CWD, and resets it to
// packages/jsx-email, which causes the config not to be found. so we use npx instead
})`email create BatmanEmail --out ./.test/emails `;
const plain = strip(stdout);

console.log(plain);

expect(plain).toContain('Creating a new template at ');
expect(plain).toContain('Template BatmanEmail.tsx created');

const contents = readFile(join(__dirname, '.test/emails/BatmanEmail.tsx'), 'utf8');
expect(contents).toMatchSnapshot();
});
});

0 comments on commit 00fcad0

Please sign in to comment.