Jest Mongo并发测试报错:TypeError: Cannot read 'getConnectionString' of undefined
Jest多测试文件运行时Mongo测试报错:TypeError: Cannot read property 'getConnectionString' of undefined
我碰到了一个疑似Jest的Bug,目前正在跟进相关问题的进展。我严格按照Jest官方文档配置并运行Mongo相关测试,但当同时运行多个测试文件时,触发了如下错误:
TypeError: Cannot read property 'getConnectionString' of undefined
错误发生在自定义Mongo环境类的setup方法中,具体代码位置如下:
3 | class MongoEnvironment extends NodeEnvironment { 4 | async setup () { >5 | this.global.__MONGO_URI__ = await global.__MONGOD__.getConnectionString() 6 | this.global.__MONGO_DB_NAME__ = global.__MONGO_DB_NAME__ 7 | 8 | await super.setup()
内容的提问来源于stack exchange,提问作者cyberwombat
相关产品推荐
相关产品推荐

