摩卡超级测试ECONNRESET

摩卡超级测试ECONNRESET

本文介绍了摩卡超级测试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?

推荐答案

我在此 Google网上论坛帖子,作者:Mike Gradek:

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

这样编写的代码如下:

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(...);

我也是.

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

08-24 06:17