New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

mock-os

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mock-os

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

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

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

Keywords

os

FAQs

Package last updated on 28 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts