Skip to content

Commit

Permalink
Fix test that randomly started failing with node:test:persistence (#6001
Browse files Browse the repository at this point in the history
)
  • Loading branch information
schmidt-sebastian committed Feb 11, 2022
1 parent c1b9cf1 commit 50de44c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/firestore/test/unit/local/indexeddb_persistence.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -787,19 +787,21 @@ describe('IndexedDbSchema: createOrUpgradeDb', () => {
DbCollectionParentKey,
DbCollectionParent
>(DbCollectionParent.store);
return collectionParentsStore.loadAll().next(indexEntries => {
const actualParents: { [key: string]: string[] } = {};
for (const { collectionId, parent } of indexEntries) {
// We use iterate() as loadAll() does not seem to guarantee ordering
// with our IndexedDB shim.
const actualParents: { [key: string]: string[] } = {};
return collectionParentsStore
.iterate((_, { collectionId, parent }) => {
let parents = actualParents[collectionId];
if (!parents) {
parents = [];
actualParents[collectionId] = parents;
}
parents.push(decodeResourcePath(parent).toString());
}

expect(actualParents).to.deep.equal(expectedParents);
});
})
.next(() => {
expect(actualParents).to.deep.equal(expectedParents);
});
}
);
});
Expand Down

0 comments on commit 50de44c

Please sign in to comment.