Skip to content

Commit

Permalink
fix(logging): relax ThrottledAnalytics two-session test (#1667)
Browse files Browse the repository at this point in the history
Because file system operations are not guaranteed to complete in the
order in which they were started, this test was previously flaky.

It seems in line with the goals of the test to just allow either
session to “win” the lock file, so do that instead.
  • Loading branch information
addaleax authored Sep 11, 2023
1 parent 7961b74 commit d3cce80
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/logging/src/analytics-helpers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,12 @@ describe('analytics helpers', function () {

expect(events).to.have.lengthOf(4);
expect(
events.filter((e) => e[0] === 'track').map((e) => e[1].event)
).to.deep.eq(['hi', 'hi', 'hi']);
events
.filter((e) => e[0] === 'track')
.map((e) => e[1].event)
.join(',')
// can't be fully sure which instance 'won' the lock because fs operations are inherently subject to race conditions
).to.match(/^(hi,hi,hi|bye,bye,bye)$/);
});
});
});

0 comments on commit d3cce80

Please sign in to comment.