Skip to content

Commit fda53d2

Browse files
authored
test: fix flaky tracing test. (#2245)
Fixes #2244.
1 parent 1ddb62e commit fda53d2

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

dev/system-test/tracing.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,12 @@ describe('Tracing Tests', () => {
433433
if (success) {
434434
buildSpanMaps();
435435
}
436-
expect(spanIdToSpanData.size).to.equal(
436+
437+
// Tests are able to perform some Firestore operations inside
438+
// `runFirestoreOperationInRootSpan`, and some Firestore operations outside
439+
// of it. Therefore, if a given test intends to capture some (but not all) spans,
440+
// the in-memory trace will have more spans than `numExpectedSpans`.
441+
expect(spanIdToSpanData.size).to.greaterThanOrEqual(
437442
numExpectedSpans,
438443
`Could not find expected number of spans (${numExpectedSpans})`
439444
);
@@ -812,6 +817,10 @@ describe('Tracing Tests', () => {
812817
});
813818

814819
it('document reference update()', async () => {
820+
// Make sure the document exists before updating it.
821+
// Perform the `set` operation outside of the root span.
822+
await firestore.collection('foo').doc('bar').set({foo: 'bar'});
823+
815824
await runFirestoreOperationInRootSpan(() =>
816825
firestore.collection('foo').doc('bar').update('foo', 'bar2')
817826
);

0 commit comments

Comments
 (0)