Supertest + Knex.js =当前客户端没有定义池

我使用超级(在摩卡内)来testing我的应用程序,这是目前使用knex.js数据库的目的。

一切正常和knex的旧版本,(0.5.x)。 现在我想用最新的knex版本。

在大多数情况下,使用

request = supertest(app) 

对我来说工作正常,但还有其他情况下我需要testing几个请求,而不重复使用Cookie,所以…

 request = supertest.agent(app) 

这发生了什么?

它结束了主题中描述的错误。 我已经添加了一些自定义日志“acquireConnection”,“releaseConnection”,“initializePool”和“destroy”函数到内核库,看看发生了什么,输出如下所示:

 Adquiring connection from pool {someCustomPoolIdYSet) Adquiring connection from pool {someCustomPoolIdYSet) Releasing connection from pool {someCustomPoolIdYSet) Adquiring connection from pool {someCustomPoolIdYSet) Adquiring connection from pool undefined [Error] ........ "There is no pool defined on the current client" 

任何帮助,将不胜感激。 提前致谢。

所以,最后我们发现了!

问题是Passport.js,默认情况下总是被用作单例。 每次我们启动应用程序,一个新的序列化器被注入护照,但它保留了以前的。 然后,那些在开始时被注入的游泳池被摧毁了……而且繁荣!