1'use strict'; 2 3// This tests support for the dns module in snapshot. 4 5require('../common'); 6const assert = require('assert'); 7const tmpdir = require('../common/tmpdir'); 8const fixtures = require('../common/fixtures'); 9const { buildSnapshot, runWithSnapshot } = require('../common/snapshot'); 10const { 11 addresses: { DNS4_SERVER, INET4_IP, INET4_HOST }, 12} = require('../common/internet'); 13 14const entry = fixtures.path('snapshot', 'dns-resolve.js'); 15const env = { 16 NODE_TEST_IP: INET4_IP, 17 NODE_TEST_HOST: INET4_HOST, 18 NODE_TEST_DNS: DNS4_SERVER, 19 NODE_TEST_PROMISE: 'false', 20}; 21 22tmpdir.refresh(); 23function checkOutput(stderr, stdout) { 24 assert(stdout.includes('hostnames: [')); 25 assert(stdout.includes('addresses: [')); 26 assert.strictEqual(stdout.trim().split('\n').length, 2); 27} 28{ 29 const { stderr, stdout } = buildSnapshot(entry, env); 30 checkOutput(stderr, stdout); 31} 32 33{ 34 const { stderr, stdout } = runWithSnapshot(entry, env); 35 checkOutput(stderr, stdout); 36} 37