MCPcopy Create free account
hub / github.com/ChromeDevTools/devtools-frontend / expectVeEvents

Function expectVeEvents

front_end/ui/visual_logging/Debugging.ts:755–788  ·  view source on GitHub ↗
(expectedEvents: TestLogEntry[])

Source from the content-addressed store, hash-verified

753 * Unexpected VE events are ignored.
754 **/
755export async function expectVeEvents(expectedEvents: TestLogEntry[]): Promise<void> {
756 if (pendingEventExpectation) {
757 throw new Error('VE events expectation already set. Cannot set another one until the previous is resolved');
758 }
759 const {promise, resolve: success, reject: fail} = Promise.withResolvers<void>();
760 pendingEventExpectation = {expectedEvents, success, fail, unmatchedEvents: []};
761 checkPendingEventExpectation();
762
763 const timeout = setTimeout(() => {
764 if (pendingEventExpectation?.missingEvents?.length) {
765 const allLogs = veDebugEventsLog.filter(ve => {
766 if ('interaction' in ve) {
767 // Very noisy in the error and not providing context
768 return ve.interaction !== 'SettingAccess';
769 }
770
771 return true;
772 });
773 pendingEventExpectation.fail(new Error(`
774Missing VE Events:
775${formatVeEvents(pendingEventExpectation.missingEvents)}
776Unmatched VE Events:
777${formatVeEvents(pendingEventExpectation.unmatchedEvents)}
778All events:
779${JSON.stringify(allLogs, null, 2)}
780`));
781 }
782 }, EVENT_EXPECTATION_TIMEOUT);
783
784 return await promise.finally(() => {
785 clearTimeout(timeout);
786 pendingEventExpectation = null;
787 });
788}
789
790let numMatchedEvents = 0;
791

Callers

nothing calls this directly

Calls 4

formatVeEventsFunction · 0.85
stringifyMethod · 0.65
filterMethod · 0.45

Tested by

no test coverage detected