1. std-mocks
Mock node stdout and stderr without pain.
std-mocks
Package: std-mocks
Created by: gregberge
Last modified: Fri, 06 Oct 2023 13:25:06 GMT
Version: 2.0.0
License: MIT
Downloads: 12,739
Repository: https://github.com/gregberge/react-merge-refs

Install

npm install std-mocks
yarn add std-mocks

std-mocks

Mock node stdout and stderr without pain.

Install

npm install std-mocks

Usage

 var stdMocks = require("std-mocks");

stdMocks.use();
process.stdout.write("ok");
console.log("log test\n");
stdMocks.restore();

var output = stdMocks.flush();
console.log(output.stdout); // ['ok', 'log test\n']

stdMocks.use([options])

Start mocking std output, by default both are mocked.

Options:

@param {object} [options] Options
@param {boolean} [options.stdout=true] Mock stdout
@param {boolean} [options.stderr=true] Mock stderr
@param {boolean} [options.print=false] Also print to std

stdMocks.restore([options])

Restore std output, by default both are restored.

Options:

@param {object} [options] Options
@param {boolean} [options.stdout=true] Mock stdout
@param {boolean} [options.stderr=true] Mock stderr

stdMocks.flush([options])

Flush collected data, by default both are collected.

Options:

@param {object} [options] Options
@param {boolean} [options.stdout=true] Mock stdout
@param {boolean} [options.stderr=true] Mock stderr
@returns {object} Object containing two array corresponding to outputs.

License

MIT

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin