node/test/parallel/test-os-checked-function.js
ZYSzys dcc5e51e1c tools: force common be required before any other modules
PR-URL: https://github.com/nodejs/node/pull/27650
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-05-13 19:39:34 +08:00

21 lines
571 B
JavaScript

/* eslint-disable node-core/require-common-first */
'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\)$/
});