node/test/parallel/test-os-checked-function.js
briete d197105476
os: move process.binding('os') to internalBinding
PR-URL: https://github.com/nodejs/node/pull/25087
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

Backport-PR-URL: https://github.com/nodejs/node/pull/25446
2019-01-14 13:58:09 +01:00

20 lines
519 B
JavaScript

'use strict';
// Flags: --expose_internals
const { internalBinding } = require('internal/test/binding');
// Monkey patch the os binding before requiring any other modules, including
// common, which requires the os module.
internalBinding('os').getHomeDirectory = function(ctx) {
ctx.syscall = 'foo';
ctx.code = 'bar';
ctx.message = 'baz';
};
const common = require('../common');
const os = require('os');
common.expectsError(os.homedir, {
message: /^A system error occurred: foo returned bar \(baz\)$/
});