Skip to content
File

Blob: src/workerd/api/tests/new-module-registry-dns-test.js

javascript30 lines
1// Copyright (c) 2026 Cloudflare, Inc.
2// Licensed under the Apache 2.0 license found in the LICENSE file or at:
3// https://opensource.org/licenses/Apache-2.0
4// Test that the node:dns module works correctly with the new module registry.
5// This exercises the Rust-implemented node-internal:dns module registration
6// path, which uses an adapter to bridge the Rust ModuleCallback into the
7// new BuiltinBuilder::addSynthetic API.
8 
9import { ok } from 'node:assert';
10import dns from 'node:dns';
11import dnsPromises from 'node:dns/promises';
12 
13export const basicDnsApi = {
14 test() {
15 // getServers() is a synchronous function that returns the list of
16 // configured DNS servers. It exercises the node-internal:dns module.
17 const servers = dns.getServers();
18 ok(Array.isArray(servers));
19 },
20};
21 
22export const dnsPromisesApi = {
23 test() {
24 const resolver = new dnsPromises.Resolver();
25 ok(resolver);
26 const servers = resolver.getServers();
27 ok(Array.isArray(servers));
28 },
29};