Skip to content

Commit 50de44c

Browse files
Fix test that randomly started failing with node:test:persistence (#6001)
1 parent c1b9cf1 commit 50de44c

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

packages/firestore/test/unit/local/indexeddb_persistence.test.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -787,19 +787,21 @@ describe('IndexedDbSchema: createOrUpgradeDb', () => {
787787
DbCollectionParentKey,
788788
DbCollectionParent
789789
>(DbCollectionParent.store);
790-
return collectionParentsStore.loadAll().next(indexEntries => {
791-
const actualParents: { [key: string]: string[] } = {};
792-
for (const { collectionId, parent } of indexEntries) {
790+
// We use iterate() as loadAll() does not seem to guarantee ordering
791+
// with our IndexedDB shim.
792+
const actualParents: { [key: string]: string[] } = {};
793+
return collectionParentsStore
794+
.iterate((_, { collectionId, parent }) => {
793795
let parents = actualParents[collectionId];
794796
if (!parents) {
795797
parents = [];
796798
actualParents[collectionId] = parents;
797799
}
798800
parents.push(decodeResourcePath(parent).toString());
799-
}
800-
801-
expect(actualParents).to.deep.equal(expectedParents);
802-
});
801+
})
802+
.next(() => {
803+
expect(actualParents).to.deep.equal(expectedParents);
804+
});
803805
}
804806
);
805807
});

0 commit comments

Comments
 (0)