摩卡超级测试ECONNRESET [英] mocha supertest ECONNRESET

查看:100
本文介绍了摩卡超级测试ECONNRESET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用Mocha和Supertest测试Nodejs服务器.测试套件已发展到1500多个测试.突然,尽管所有被测试的代码仍然有效,但是我的测试套件由于以下错误而失败:

I'm testing a Nodejs server with Mocha and Supertest. The test suite has grown to more than 1500 tests. Suddenly, although all of the code under test still works, my test suite fails with this error:

{ [Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }

{ [Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }

如果我注释掉了一些较早运行的测试,则导致错误的测试会更改. 是什么导致这种精神错乱?

If I comment out some tests that run earlier, the tests that cause the error change. What is causing this insanity?

推荐答案

我在此

I found the answer in this Google Groups post by Mike Gradek:

我们使用mocha和supertest发出这些请求,并意识到我们实际上是在每个请求上纺出新的端口绑定,而不是重用现有的绑定.

We used mocha and supertest to issue these requests, and realized that we were actually spinning up new port bindings on every request instead of reusing existing bindings.

这样编写的代码如下:

var request = require('supertest');
var app = require('../app');
request(app).get(...);
request(app).get(...);

蜜饯

var request = require('supertest');
var app = require('../app');
var supertest = request(app);
supertest.get(...);
supertest.get(...);

那为我们解决了这个问题.

That solved the issue for us.

我也是.

这篇关于摩卡超级测试ECONNRESET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆