EADDRINUSE 127.0.0.1:5858 在玩笑测试调试期间
EADDRINUSE 127.0.0.1:5858 during jest test debugging
避免在 Jest 测试调试期间抛出以下错误:
Error: listen EADDRINUSE 127.0.0.1:5858
at Object.exports._errnoException (util.js:1022:11)
at exports._exceptionWithHostPort (util.js:1045:20)
at Agent.Server._listen2 (net.js:1262:14)
at listen (net.js:1298:10)
at doListening (net.js:1397:7)
at _combinedTickCallback (internal/process/next_tick.js:77:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
我 运行 我的测试使用
node --harmony --debug-brk=5858 node_modules/.bin/jest
问题是 Jest 正在分叉新进程以进行 运行 测试,并且新进程正试图绑定到与父进程相同的调试端口(在本例中为 5858),并且该端口已被占用父进程。
奇怪的是,这个错误经常发生,但并不总是发生。有时上面的命令实际上允许调试测试。
使用--runInBand
jest
选项。来自文档:
--runInBand, -i
Run all tests serially in the current process
(rather than creating a worker pool of child
processes that run tests). This is sometimes
useful for debugging, but such use cases are
pretty rare. [boolean]
它只是防止 Jest 分叉。
node --harmony --debug-brk=5858 node_modules/.bin/jest --runInBand
避免在 Jest 测试调试期间抛出以下错误:
Error: listen EADDRINUSE 127.0.0.1:5858
at Object.exports._errnoException (util.js:1022:11)
at exports._exceptionWithHostPort (util.js:1045:20)
at Agent.Server._listen2 (net.js:1262:14)
at listen (net.js:1298:10)
at doListening (net.js:1397:7)
at _combinedTickCallback (internal/process/next_tick.js:77:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
我 运行 我的测试使用
node --harmony --debug-brk=5858 node_modules/.bin/jest
问题是 Jest 正在分叉新进程以进行 运行 测试,并且新进程正试图绑定到与父进程相同的调试端口(在本例中为 5858),并且该端口已被占用父进程。
奇怪的是,这个错误经常发生,但并不总是发生。有时上面的命令实际上允许调试测试。
使用--runInBand
jest
选项。来自文档:
--runInBand, -i
Run all tests serially in the current process (rather than creating a worker pool of child processes that run tests). This is sometimes useful for debugging, but such use cases are pretty rare. [boolean]
它只是防止 Jest 分叉。
node --harmony --debug-brk=5858 node_modules/.bin/jest --runInBand