
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@infragen/util-test-cli
Advanced tools
This is a generic utility that should be able to test any CLI. It's meant to be used in the context of Jest as it exports mock functions that fire when there's data on `stdout` or `stderr`
This is a generic utility that should be able to test any CLI. It's meant to be used in the context of Jest as it exports mock functions that fire when there's data on stdout
or stderr
ts-node
)timeoutBetweenInputs
To see examples of each please see tests under __tests__
import { ITestGeneratorOutput }, testCLI from '@infragen/util-test-cli';
import { SPACE, DOWN, ENTER } from '@infragen/send-input-to-cli';
const { code, error, output }: ITestCLIReturn = await testCLI({
bashCommand: `ts-node ./mockCLIs/standard.ts`,
inputs: STD_CLI_INPUTS
});
expect(error.mock.calls.length).toBe(0);
expect(code).toBe(0);
expect(output).toBeCalledWith(
expect.stringMatching(/Which option do you want to choose\?/)
);
expect(output).toBeCalledWith(expect.stringMatching(/◯ Option 1/));
expect(output).toBeCalledWith(expect.stringMatching(/◯ Option 3/));
expect(output).toBeCalledWith(expect.stringMatching(/Option 1 Chosen/));
expect(output).not.toBeCalledWith(expect.stringMatching(/Option 2 Chosen/));
expect(output).toBeCalledWith(expect.stringMatching(/Option 3 Chosen/));
expect(output).toBeCalledWith(
expect.stringMatching(/What's your full name\?/)
);
expect(output).toBeCalledWith(
expect.stringMatching(/Your name is "Anatoliy Zaslavskiy"/)
);
FAQs
This is a generic utility that should be able to test any CLI. It's meant to be used in the context of Jest as it exports mock functions that fire when there's data on `stdout` or `stderr`
We found that @infragen/util-test-cli demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.