Add a test for CLI commands

This commit is contained in:
Prathamesh Musale 2024-01-24 12:21:43 +05:30
parent 5a0298dda5
commit 821172f8ea
5 changed files with 2026 additions and 7 deletions

6
jest.config.js Normal file
View File

@ -0,0 +1,6 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
setupFiles: ["dotenv/config"]
};

View File

@ -7,21 +7,26 @@
"license": "UNLICENSED",
"devDependencies": {
"@types/fs-extra": "^9.0.13",
"@types/jest": "^27.4.1",
"@types/js-yaml": "^4.0.5",
"@types/lodash": "^4.14.182",
"@types/node": "^17.0.25",
"@types/yargs": "^17.0.10",
"jest": "29.0.0",
"ts-jest": "^29.0.2",
"dotenv": "^16.3.2",
"typescript": "^4.6.3"
},
"dependencies": {
"fs-extra": "^10.1.0",
"@cerc-io/laconic-sdk": "^0.1.14",
"fs-extra": "^10.1.0",
"js-yaml": "^3.14.1",
"lodash": "^4.17.21",
"lodash-clean": "^2.2.3",
"yargs": "^17.4.1"
},
"scripts": {
"test": "jest --runInBand --verbose --testPathPattern=test",
"lint": "eslint .",
"clean": "rm -rf ./dist",
"build": "tsc"

28
test/cli.test.ts Normal file
View File

@ -0,0 +1,28 @@
import { spawnSync } from 'child_process';
describe('Test laconic CLI commands', () => {
beforeAll(async () => {
// TODO: Install laconic binary (create symlink in path)
// TODO: Create a temp directory to run the tests in and cd into that
});
afterAll(async () => {
// TODO: Cleanup temp dir
});
test('laconic', async () => {
const result = spawnSync('laconic');
const output = result.stdout.toString().trim();
const errorOutput = result.stderr.toString().trim();
// Expect error with usage string
expect(output).toBe('');
expect(errorOutput).toContain('laconic <command>');
expect(result.status).toBe(1);
});
describe('laconic <command>', () => {
// TODO: Test subcommands
});
});

View File

@ -97,5 +97,7 @@
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
},
"include": ["src"],
"exclude": ["test"]
}

1988
yarn.lock

File diff suppressed because it is too large Load Diff