pmo

pmock

Mock any of Node's process properties for testing

Showing:

Popularity

Downloads/wk

102

GitHub Stars

5

Maintenance

Last Commit

6yrs ago

Contributors

1

Package

Dependencies

1

Size (min+gzip)

0.8KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

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();
    });

});

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100