diff --git a/test/parallel/test-os-checked-function.js b/test/parallel/test-os-checked-function.js new file mode 100644 index 00000000000..04c2c3a1f82 --- /dev/null +++ b/test/parallel/test-os-checked-function.js @@ -0,0 +1,15 @@ +'use strict'; +// Monkey patch the os binding before requiring any other modules, including +// common, which requires the os module. +process.binding('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\)$/ +});