From a9162c2d46932b3e45f7d8db360f52ea1390be81 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Wed, 16 Nov 2022 00:15:23 +0100 Subject: [PATCH] chore(ci): fix flaky unit test This is a quick band-aid to stop sleep from sometimes failing on CI https://github.com/ipfs/ipfs-webui/issues/2065#issuecomment-1315933342 --- src/bundles/peer-bandwidth.test.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bundles/peer-bandwidth.test.js b/src/bundles/peer-bandwidth.test.js index 74e1201b2..9862d9501 100644 --- a/src/bundles/peer-bandwidth.test.js +++ b/src/bundles/peer-bandwidth.test.js @@ -194,10 +194,12 @@ it('should get bandwidth for added peers', async () => { bwPeers.forEach(({ bw }) => expect(bw).toBeFalsy()) // Wait for all the bandwdith stats to come in - await sleep(30) + while (bwPeers.some(p => typeof p.bw === 'undefined')) { + await sleep(30) + bwPeers = store.selectPeerBandwidthPeers() + } // Now all the peers should have had their bandwidth updated - bwPeers = store.selectPeerBandwidthPeers() expect(bwPeers.length).toBe(peers.length) bwPeers.forEach(({ bw }) => expect(bw).toBeTruthy())