在Node.js net.Socket实例上模拟ECONNRESET错误
我正在写一些unit testing,我想在一个net.Socket实例上模拟一个连接丢失(ECONNRESET),作为其中一个testing的一部分。
什么是最好的方式去做这件事?
谢谢
我最终的方式如下:
client.end(); client.emit('error', new Error('ECONNRESET'));
是我为了testing的目的所需要的
我正在写一些unit testing,我想在一个net.Socket实例上模拟一个连接丢失(ECONNRESET),作为其中一个testing的一部分。
什么是最好的方式去做这件事?
谢谢
我最终的方式如下:
client.end(); client.emit('error', new Error('ECONNRESET'));
是我为了testing的目的所需要的