随机testing与Mongo错误

我试图找出为什么我得到随机错误与下面的代码

const Mongo = require('mongodb') it.only('x', async () => { let db const url = `mongodb://test.localhost:27017/nako`; db = await Mongo.connect(url) await db.dropDatabase() db = await Mongo.connect(url) let collection = await db.createCollection('accounts') await collection.createIndex( { login : 1}, {unique: true }) await collection.insert({name: 'yo', login: 'one'}) }) 

虽然我完全摧毁了数据库并重新构build,但我得到了两个随机错误:

  • 集合已经存在
  • 重复键错误收集(login时)

我在哪个部分不等待指令结束? 还是我使用任何types的陈旧价值?