Does Vitest support refreshing DNS cache during a test run?
0 reputation · 26 Dec 2020, 02:32 UTC
When running long‑running Vitest suites, tests may need to connect to hostnames whose IP addresses change due to VPN reconfiguration, split‑horizon DNS, or dynamic service discovery.
Vitest resolves the server.host option once at process start using Node’s built‑in dns.resolve* functions and relies on Node’s internal DNS cache, which is not exposed for flushing or for specifying custom resolvers.
Because there is no configuration knob to refresh the cache or to disable caching, a change in the system resolver after Vitest has started can leave tests using stale IP addresses, leading to connection failures or incorrect test outcomes.
Does Vitest currently provide any API or option to clear or reload its internal DNS cache during a test run? Can Vitest be configured to bypass Node’s DNS cache for the test server? Should Vitest automatically monitor resolver changes and refresh cached resolutions?