I was trying to use the virtual-serialport package to mock some code that worked fine with node-serialport and actual hardware. However, virtual-serialport makes synchronous emit() calls, meaning that instead of being able to assign callbacks/event handlers after open/write/etc, callbacks execute during the call (.write() calls emit("data") which calls all callbacks right then). Emits should be wrapped in something like setImmediate in order to simulate expected usage.
I was trying to use the virtual-serialport package to mock some code that worked fine with node-serialport and actual hardware. However, virtual-serialport makes synchronous emit() calls, meaning that instead of being able to assign callbacks/event handlers after open/write/etc, callbacks execute during the call (.write() calls emit("data") which calls all callbacks right then). Emits should be wrapped in something like setImmediate in order to simulate expected usage.