pmock

v0.2.3
Mock any process property of Node.
environment variables process mock mock process stub process mocking environment mock env mock env mocking

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

});
npm i pmock

Metadata

  • MIT
  • Whatever
  • Arjan Frans
  • released 12/13/2015

Downloads

Maintainers