From 830dc340b04bc8f1f6b0e9f5773d1be54d9e5549 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Thu, 9 Jul 2026 09:52:24 +0200 Subject: [PATCH] test(node-core): Fix flaky withMonitor span order assertion The withMonitor integration test asserted span order via toMatchObject, but the span exporter does not guarantee child span order. Assert span presence with toContainEqual instead. Fixes #22121 Co-Authored-By: Cursor Co-authored-by: Cursor --- .../node-core/test/integration/transactions.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/node-core/test/integration/transactions.test.ts b/packages/node-core/test/integration/transactions.test.ts index e00cbc8580d1..32e41ffebc68 100644 --- a/packages/node-core/test/integration/transactions.test.ts +++ b/packages/node-core/test/integration/transactions.test.ts @@ -722,12 +722,12 @@ describe('Integration | Transactions', () => { expect(beforeSend).toHaveBeenCalledTimes(1); expect(transactionEvents).toHaveLength(1); expect(transactionTraceId).toBe(errorTraceId); - expect(transactionEvents[0]?.spans).toHaveLength(3); - expect(transactionEvents).toMatchObject([ - { - spans: [{ description: 'inner span 1' }, { description: 'span inside error' }, { description: 'inner span 2' }], - }, - ]); + const spans = transactionEvents[0]?.spans || []; + + expect(spans).toHaveLength(3); + expect(spans).toContainEqual(expect.objectContaining({ description: 'inner span 1' })); + expect(spans).toContainEqual(expect.objectContaining({ description: 'span inside error' })); + expect(spans).toContainEqual(expect.objectContaining({ description: 'inner span 2' })); expect(sendEvents).toMatchObject([ { exception: {