diff --git a/test/parallel/test-dns-resolve-promises.js b/test/parallel/test-dns-resolve-promises.js new file mode 100644 index 00000000000000..783ed2a709edb6 --- /dev/null +++ b/test/parallel/test-dns-resolve-promises.js @@ -0,0 +1,20 @@ +// Flags: --expose-internals +'use strict'; +require('../common'); +const assert = require('assert'); +const { internalBinding } = require('internal/test/binding'); +const cares = internalBinding('cares_wrap'); +const { UV_EPERM } = internalBinding('uv'); +const dnsPromises = require('dns').promises; + +// Stub cares to force an error so we can test DNS error code path. +cares.ChannelWrap.prototype.queryA = () => UV_EPERM; + +assert.rejects( + dnsPromises.resolve('example.org'), + { + code: 'EPERM', + syscall: 'queryA', + hostname: 'example.org' + } +);