![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
cli-testing-tool
Advanced tools
A testing library that allows you to test input and outputs of your CLI command.
A testing library that allows you to test input and outputs of your CLI command.
Note: This is WIP but it should be ready enough for most common CLI use-cases I can think of
With NPM:
npm install --save-dev cli-testing-tool
With Yarn:
yarn add --dev cli-testing-tool
Check out Interactive Examples on Stackblitz
Check out this example of StackBlitz
// colored-greeting.test.js
const { createCommandInterface } = require('cli-testing-tool');
test('should print colored greetings', async () => {
const commandInterface = createCommandInterface('node ./graphic-print.js', {
cwd: __dirname, // considering, the test file is in the same directory as the cli file
});
await commandInterface.type('Saurabh\n');
const terminal = await commandInterface.getOutput();
// ANSI Escape codes are tokenized into readable text token in tokenizedOutput
// Helpful when libraries like inquirer or prompts add ansi-escape codes.
expect(terminal.tokenizedOutput).toBe(
"What's your name?Hi, [BOLD_START][RED_START]Saurabh[COLOR_END][BOLD_END]!"
);
// ANSI Escape codes are not tokenized.
expect(terminal.rawOutput).toBe(
`What's your name?Hi, \x1B[1m\x1B[31mSaurabh\x1B[39m\x1B[22m!`
);
// ANSI Escape codes are removed
expect(terminal.stringOutput).toBe(`What's your name?Hi, Saurabh!`);
});
// colored-greeting.js
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
const bold = (str) => `\x1b[1m${str}\x1b[22m`;
const red = (str) => `\x1b[31m${str}\x1b[39m`;
readline.question(`What's your name?`, (name) => {
console.log(`Hi, ${bold(red('Saurabh'))}!`);
readline.close();
});
You can pass options as 2nd param to createCommandInterface
.
The default options are:
const defaultOptions = {
typeDelay: 100, // number. delay between each `.type()` call
logData: false, // boolean. if true, logs the command data on terminal
logError: true, // boolean. if false, won't add command errors on terminal
cwd: process.cwd(), // string. working directory from where your simulated command is executed
env: undefined // object | undefined. environment variables object if there are any
};
Refer to Full List of Ansi Escape Codes that need to be handled.
Big Shoutout to
@fnky for the list of all ansi escape codes.
@netzkolchose for node-ansiterminal library.
FAQs
A testing library that allows you to test input and outputs of your CLI command.
The npm package cli-testing-tool receives a total of 2 weekly downloads. As such, cli-testing-tool popularity was classified as not popular.
We found that cli-testing-tool 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
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.