Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
mock-console-es
Advanced tools
Mock-Console-ES is a small ES module implementation of a console mock. It allows enabling, disabling, and capturing the output of the built-in console methods.
npm install mock-console-es
import MockConsole from 'mock-console-es';
const logger = new MockConsole()
Note: The mock is a singleton. Every time new
is called on the mock it'll return the same instance
Disables the built-in console methods (ie log
, info
, error
)
const logger = new MockConsole();
logger.disable();
console.log('This will NOT print to the console');
Restores the built-in console methods after they've been disabled
const logger = new MockConsole();
logger.disable();
console.log('This will NOT print to the console');
logger.restore();
console.log('This WILL print to the console');
> This WILL print to the console
Capture is used to store the console output so it can be retrieved later for testing
const logger = new MockConsole();
logger.capture();
console.log('This message will be captured');
logger.restore();
console.log(logger.logs);
> [ 'This message will be captured' ]
Captured logs are stored in an array
console.log
-> MockConsole.logs[]
console.info
-> MockConsole.infos[]
console.error
-> MockConsole.errors[]
Flush removes all previously captured logs
const logger = new MockConsole();
logger.capture();
console.log('This message will be captured');
logger.restore();
console.log(logger.logs);
> [ 'This message will be captured' ]
logger.flush();
console.log(logger.logs);
> []
A .cjs
bundle is included for CommonJS compatibility
const { MockConsole } = require('mock-console-es');
Typings are generated from JSDoc using Typescript. They are 100% compatible with VSCode Intellisense and will work seamlessly with Typescript.
FAQs
Mock and trap the console for testing
The npm package mock-console-es receives a total of 0 weekly downloads. As such, mock-console-es popularity was classified as not popular.
We found that mock-console-es 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.