0.2.3 • Published 10 years ago

pmock v0.2.3

Weekly downloads
219
License
MIT
Repository
github
Last release
10 years ago

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

});