From d3cce807871f5e130e7ba9418fa755f55dadb145 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 11 Sep 2023 18:01:22 +0200 Subject: [PATCH] fix(logging): relax ThrottledAnalytics two-session test (#1667) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- packages/logging/src/analytics-helpers.spec.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/logging/src/analytics-helpers.spec.ts b/packages/logging/src/analytics-helpers.spec.ts index 072ee8b7c..9f83063e3 100644 --- a/packages/logging/src/analytics-helpers.spec.ts +++ b/packages/logging/src/analytics-helpers.spec.ts @@ -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)$/); }); }); });