Ask HN: What should I use to run React Native tests on a device?

3 points by dboreham 18 hours ago

Something of a common problem in JS/TS-land, I've found is that unit tests are expected to be run in a Node.js process. In the past in various projects this approach proved problematic because "environment parity" with the target runtime (browser) couldn't be achieved (e.g. no WebRTC[1]). In those projects we resolved this problem by writing our own test runner that could be injected into a headless browser process.

So now the same sort of problem has arisen with a mobile device project using react native: I assumed that unit tests would be runnable on a device or at least an emulator, but it seems not (see: https://docs.expo.dev/develop/unit-testing/). Or at least so far I haven't found the secret sauce or tool to allow that. Any pointers welcome.

[1]Yes there is a WebRTC port for Node that uses an old version of Google's C++ library, but it doesn't actually work properly.