From bd8b10c639630d694d814bdfb587bf969b47c3b8 Mon Sep 17 00:00:00 2001 From: Tofandel Date: Wed, 30 Oct 2024 15:02:54 +0100 Subject: [PATCH] Add test --- test/report/test-report-exclude-network.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/report/test-report-exclude-network.js b/test/report/test-report-exclude-network.js index c5e50135482f1a..d4bd6b117f6ebd 100644 --- a/test/report/test-report-exclude-network.js +++ b/test/report/test-report-exclude-network.js @@ -38,4 +38,22 @@ describe('report exclude network option', () => { const report = process.report.getReport(); assert.strictEqual(report.header.networkInterfaces, undefined); }); + + it('should not do DNS queries in libuv if exclude network', async () => { + await fetch('http://localhost'); + + process.report.excludeNetwork = false; + let report = process.report.getReport(); + let tcp = report.libuv.find((uv) => uv.type === 'tcp'); + assert.notEqual(tcp, null); + assert.strictEqual(tcp.localEndpoint.host, 'localhost'); + assert.strictEqual(tcp.remoteEndpoint.host, 'localhost'); + + process.report.excludeNetwork = true; + report = process.report.getReport(); + tcp = report.libuv.find((uv) => uv.type === 'tcp'); + assert.notEqual(tcp, null); + assert.strictEqual(tcp.localEndpoint.host, '127.0.0.1'); + assert.strictEqual(tcp.remoteEndpoint.host, '127.0.0.1'); + }); });