Skip to content

Commit 6c24bc6

Browse files
committed
test: wait for async telemetry exception event in unknownActivity test
The onTelemetry exception event fires asynchronously after activities are rendered. Add a pageConditions.became() wait before asserting on it to avoid a race condition where the assertion runs before the event fires.
1 parent 0e46c91 commit 6c24bc6

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

__tests__/html2/activity/legacy/unknownActivity.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@
7070
expect(consoleError.mock.calls[0][0].message).toBe('No renderer for activity of type "x-unknown-activity"');
7171

7272
// THEN: Should emit as exception event.
73+
// The telemetry event fires asynchronously; wait for it to appear.
74+
await pageConditions.became(
75+
'telemetry exception event for unknown activity',
76+
() => onTelemetry.mock.calls.some(call => call[0]?.type === 'exception'),
77+
2000
78+
);
79+
7380
const exceptionEvent = onTelemetry.mock.calls.find(call => call[0]?.type === 'exception');
7481

7582
expect(exceptionEvent).toBeTruthy();

0 commit comments

Comments
 (0)