Gosh I do love how elegant Playwright + my little Kitten¹ process helper makes it to write end-to-end tests.
Check out the tests for the peer-to-peer web (Small Web) end-to-end encrypted chat example²:
https://codeberg.org/kitten/app/src/branch/main/tests/end-to-end/peer-to-peer.spec.js
That handles the setting up of two instances (place1.localhost:498 and place2.localhost:499) and tests the sending of end-to-end encrypted messages between them.
:kitten:💕
¹ https://kitten.small-web.org
² https://codeberg.org/kitten/app/src/branch/main/examples/streaming-html/kitten-chat/animated-end-to-end-encrypted