1'use strict'; 2// Flags: --expose-internals 3 4require('../common'); 5const { internalBinding } = require('internal/test/binding'); 6const assert = require('assert'); 7 8// Monkey patch the os binding before requiring any other modules, including 9// common, which requires the os module. 10internalBinding('os').getHomeDirectory = function(ctx) { 11 ctx.syscall = 'foo'; 12 ctx.code = 'bar'; 13 ctx.message = 'baz'; 14}; 15 16const os = require('os'); 17 18assert.throws(os.homedir, { 19 message: /^A system error occurred: foo returned bar \(baz\)$/ 20}); 21