Files
triggerdotdev--trigger.dev/packages/cli/test/example.test.ts
Wesley 4ca9f182d7 test/TRI 887/setup jest on cli package (#326)
* chore: run `pnpm install --prefer-frozen-lockfile`

* chore: install `jest` and `ts-jest`

* test: create `jest.config.js`

* chore: install `@types/jest`

* chore: add `jest` on `tsconfig.json` `types` property

* chore: create test script

* test: create example test 🎉🎊🕺🏼

* chore: install `@gmrchk/cli-testing-library`

* chore: override `tsconfig` with `@trigger.dev/tsconfig`

* test: make poc of cli test

* chore: run build before test

* docs: improve comment

* Added a changeset

---------

Co-authored-by: Matt Aitken <matt@mattaitken.com>
2023-08-16 22:35:23 +01:00

39 lines
1.2 KiB
TypeScript

import { prepareEnvironment } from "@gmrchk/cli-testing-library";
import { CLITestEnvironment } from "@gmrchk/cli-testing-library/lib/types";
import { join } from "node:path";
let environment: CLITestEnvironment;
beforeAll(async () => {
// This will create a sandbox folder under `/var/folders`
environment = await prepareEnvironment();
});
afterAll(async () => {
await environment.cleanup();
});
describe('cli', () => {
// can be any path with a nextjs project
const NEXT_PROJECT_PATH = join(__dirname, '..', '..', '..', 'examples', 'nextjs-example');
it('should be able to execute cli', async () => {
const { waitForText, getStdout, wait, pressKey } = await environment.spawn('node', `${join(__dirname, '..', 'dist', 'index.js')} init -p ${NEXT_PROJECT_PATH}`)
console.log('getStdout() :>> ', getStdout());
await waitForText('Detected Next.js project');
console.log('getStdout() :>> ', getStdout());
await waitForText('Are you using the Trigger.dev cloud or self-hosted?');
console.log('getStdout() :>> ', getStdout());
await pressKey('enter');
console.log('getStdout() :>> ', getStdout());
// wait next prompt, make assertions and keep going
});
})