Dealing with tests that require networking support

I’m in the process of packaging a library in Nixpkgs, but the library in question’s test suite includes connecting to an external websocket server. While building the package on linux this test (and similar ones) fail because of the lack of network support in the sandbox. As an example here is one of the tests that fail:

Jumping into the build environment confirms that the “” name does not resolve / attempting a connection with the IP fails because the network is unreachable.

I considered patching the test suite to remove these tests with external network dependencies for the Nixpkgs build, but I wondered if there is a better or preferred solution for this type of issue?

I haven’t had to deal with networking tests yet, but AFAIK disabling is correct for package tests.

Disabling tests that do networking is typically done. Reaching out to the network is considered impure, so we don’t want that in nixpkgs.

It is however possible to do NixOS tests that require a network connection. Depending on your use case that may do the trick.

1 Like