jeudi 9 avril 2015

NodeJS: How can I create a fake tcp socket for testing servers

I'm trying to unit test my server code (non-http, custom protocol). I need to create a fake duplex socket that I can send messages to asynchronously and receive messages from.


I've had some marginal success creating a duplex stream from event-stream readArray and writeArray, but readArray requires having the data up front, and writeArray doesn't fire until the stream ends. I need to test over time.


Are there any existing solutions for this? I'd rather not have to resort to initializing an actual server to test this.


Aucun commentaire:

Enregistrer un commentaire