Running eunit tests in a separate node?

I’ve got a legacy application that doesn’t clean up properly (it leaves stuff in persistent_term, etc.), and I’d like to isolate it in another BEAM, so it just gets nuked when the test suite finishes.

Is there a way to run an eunit test suite, such that the setup, foreach, etc., run in a separate node?

I’ve looked at node, but all that does is spawn another node; it doesn’t actually seem to run anything on that node.

Got it, but it’s ugly, because of Eunit: {node, ... instantiator broken in OTP-28.x , and because of the need to copy the code search path:

-module(node_test).
-include_lib("eunit/include/eunit.hrl").

node_spawn_test_() ->
    {node, 'foo', fun({Pid, _}) ->
        Node = get_peer_node(Pid),
        erpc:call(Node, code, set_path, [code:get_path()]),

        {spawn, Node, [
            {setup, fun remote_setup/0, [
                fun remote/0
            ]}
        ]}
    end}.

get_peer_node(Pid) ->
    gen_server:call(Pid, get_node).

remote_setup() ->
    ?assertEqual(moo, node()).

remote() ->
    ?assertEqual(moo, node()).