Add a test for CLI commands
This commit is contained in:
parent
5a0298dda5
commit
821172f8ea
6
jest.config.js
Normal file
6
jest.config.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
|
||||||
|
module.exports = {
|
||||||
|
preset: 'ts-jest',
|
||||||
|
testEnvironment: 'node',
|
||||||
|
setupFiles: ["dotenv/config"]
|
||||||
|
};
|
@ -7,21 +7,26 @@
|
|||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/fs-extra": "^9.0.13",
|
"@types/fs-extra": "^9.0.13",
|
||||||
|
"@types/jest": "^27.4.1",
|
||||||
"@types/js-yaml": "^4.0.5",
|
"@types/js-yaml": "^4.0.5",
|
||||||
"@types/lodash": "^4.14.182",
|
"@types/lodash": "^4.14.182",
|
||||||
"@types/node": "^17.0.25",
|
"@types/node": "^17.0.25",
|
||||||
"@types/yargs": "^17.0.10",
|
"@types/yargs": "^17.0.10",
|
||||||
|
"jest": "29.0.0",
|
||||||
|
"ts-jest": "^29.0.2",
|
||||||
|
"dotenv": "^16.3.2",
|
||||||
"typescript": "^4.6.3"
|
"typescript": "^4.6.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fs-extra": "^10.1.0",
|
|
||||||
"@cerc-io/laconic-sdk": "^0.1.14",
|
"@cerc-io/laconic-sdk": "^0.1.14",
|
||||||
|
"fs-extra": "^10.1.0",
|
||||||
"js-yaml": "^3.14.1",
|
"js-yaml": "^3.14.1",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"lodash-clean": "^2.2.3",
|
"lodash-clean": "^2.2.3",
|
||||||
"yargs": "^17.4.1"
|
"yargs": "^17.4.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"test": "jest --runInBand --verbose --testPathPattern=test",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"clean": "rm -rf ./dist",
|
"clean": "rm -rf ./dist",
|
||||||
"build": "tsc"
|
"build": "tsc"
|
||||||
|
28
test/cli.test.ts
Normal file
28
test/cli.test.ts
Normal 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
|
||||||
|
});
|
||||||
|
});
|
@ -97,5 +97,7 @@
|
|||||||
/* Completeness */
|
/* Completeness */
|
||||||
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
||||||
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
||||||
}
|
},
|
||||||
|
"include": ["src"],
|
||||||
|
"exclude": ["test"]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user