node/test/parallel/test-os-checked-function.js
Juan José Arboleda 7534477786
test: replace flag expose_internals to expose-internals
PR-URL: https://github.com/nodejs/node/pull/32542
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-04-02 18:28:23 +02:00

21 lines
532 B
JavaScript

'use strict';
// Flags: --expose-internals
require('../common');
const { internalBinding } = require('internal/test/binding');
const assert = require('assert');
// 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 os = require('os');
assert.throws(os.homedir, {
message: /^A system error occurred: foo returned bar \(baz\)$/
});