pmock
v0.2.3 environment variables process mock mock process stub process mocking environment mock env mock env mocking
pmock
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();
});
});