I've written a module that uses ioredis and some tests to go along with it.
The problem is, that when I it when ioredis is connected in cluster mode, mocha hangs after finish, even though I call redis.disconnect().
It seems that something is still bound to the event loop.
Here is my test:
it('connects to redis cluster mode', async () => {
//redisClientFactroy is my module
let redisClientFactory = redisClientFactoryInit({
host: 'localhost',
port: 7000
})
// it returns a redis.cluster instance if it recognizes it
// 'redis' here is a cluster client
let redis = await redisClientFactory.createClient()
await redis.set('took123', 1);
let took = await redis.get('took123')
expect(took).to.eql('1')
let nodes = redis.nodes()
await Promise.all(nodes.map((node) => {
node.disconnect()
console.log("node disconnected")
}))
redis.disconnect()
//tests are marked as done and passing, but mocha does not exit
})