
Research
/Security News
11 Malicious Go Packages Distribute Obfuscated Remote Payloads
Socket uncovered 11 malicious Go packages using obfuscated loaders to fetch and execute second-stage payloads via C2 domains.
cli-testing-library
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 a work in progress. The API is likely going to change.
Terminal Text Parsing Support Checklist Refer to Full List of Ansi Escape Codes that need to be handled.
With NPM:
npm install --save-dev cli-testing-library
With Yarn:
yarn add --dev cli-testing-library
Test file
// experiment.test.js
const { createCommandInterface } = require('cli-testing-library');
test('should print appropriate greetings', async () => {
const commandInterface = createCommandInterface('node ./experiment.js', {
cwd: __dirname
});
await commandInterface.type('Saurabh\n');
await commandInterface.type('22\n');
const terminal = await commandInterface.getOutput();
expect(terminal.textAfter("What's your name?")).toBe('Hi, Saurabh!');
expect(terminal.textAfter("What's your age?")).toBe('So you are 22!');
});
Code that is being tested A node program that asks user for their name and age, and then prints a greeting.
// experiment.js
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
readline.question(`What's your name?`, (name) => {
console.log(`Hi, ${name}!`);
readline.question(`What's your age?`, (age) => {
console.log(`So you are ${age}!`);
readline.close();
});
});
FAQs
Simple and complete CLI testing utilities that encourage good testing practices.
The npm package cli-testing-library receives a total of 2,145 weekly downloads. As such, cli-testing-library popularity was classified as popular.
We found that cli-testing-library demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
/Security News
Socket uncovered 11 malicious Go packages using obfuscated loaders to fetch and execute second-stage payloads via C2 domains.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).