1. pmock
Mock any process property of Node.
pmock
Package: pmock
Created by: arjanfrans
Last modified: Fri, 24 Jun 2022 05:03:11 GMT
Version: 0.2.3
License: MIT
Downloads: 541
Repository: https://github.com/arjanfrans/node-pmock

Install

npm install pmock
yarn add pmock

pmock

NPM

GitHub version
Build Status
Dependency Status
devDependency Status
Coverage Status

Mock any of the process properties of Node.
Useful to mock things in tests, for example: environment variables, memory usage or the current working directory.

Any process property not used in the global scope (of a module) will can be mocked.

Example

Here is an example usage in a mocha test:

describe('pmock test', function() {

    before(function() {
        // Replace 'env' in this case.
        this.env = pmock.env({
            ENVMOCK_TEST: 'hello'
        });
        // Mock 'cwd()'
        this.cwd = pmock.cwd(__dirname + '/somelocation');
    });

    it('...', function() {
        // Some tests of functions that uses process.env and process.cwd()
    });

    after(function() {
        // Reset back to original value.
        this.env.reset();
        this.cwd.reset();
    });

});

Dependencies

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