Navigation Menu

Skip to content

lfortin/node-mock-os

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mock-os

mock-os is a testing module for the os core module in Node.js.

Installation

npm install --save-dev mock-os

Example

The code below makes it so the os module can output fake system metrics.

var mock = require('mock-os');

mock({
  'freemem': 100000,
  'loadavg': [2, 2, 2],
  'homedir': '/Users/username'
});

When you are ready to restore the os module to its original behavior, call mock.restore().

// after a test runs
mock.restore();

About

Testing module for the os built-in module in Node.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published