MockLogger Class
The MockLogger records events sent to it, and then can walk back over those events searching for a set of expected events to match against the logged events.
Signature
export declare class MockLogger extends TelemetryLogger implements ITelemetryLogger
Extends: TelemetryLogger
Implements: ITelemetryLogger
Constructors
Constructor | Description |
---|---|
(constructor)() | Constructs a new instance of the MockLogger class |
Properties
Property | Type | Description |
---|---|---|
events | ITelemetryBaseEvent[] |
Methods
Method | Return Type | Description |
---|---|---|
assertMatch(expectedEvents, message) | void | Asserts that matchEvents is true, and prints the actual/expected output if not |
assertMatchAny(expectedEvents, message) | void | Asserts that matchAnyEvent is true, and prints the actual/expected output if not |
clear() | void | |
matchAnyEvent(expectedEvents) | boolean | Search events logged since the last time matchEvents was called, looking for any of the given expected events. |
matchEvents(expectedEvents) | boolean | Search events logged since the last time matchEvents was called, looking for the given expected events in order. |
send(event) | void |
Constructor Details
(constructor)
Constructs a new instance of the MockLogger
class
Signature
constructor();
Property Details
events
Signature
events: ITelemetryBaseEvent[];
Type: ITelemetryBaseEvent[]
Method Details
assertMatch
Asserts that matchEvents is true, and prints the actual/expected output if not
Signature
assertMatch(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string): void;
Parameters
Parameter | Modifiers | Type | Description |
---|---|---|---|
expectedEvents | Omit<ITelemetryBaseEvent, "category">[] | ||
message | optional | string |
assertMatchAny
Asserts that matchAnyEvent is true, and prints the actual/expected output if not
Signature
assertMatchAny(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string): void;
Parameters
Parameter | Modifiers | Type | Description |
---|---|---|---|
expectedEvents | Omit<ITelemetryBaseEvent, "category">[] | ||
message | optional | string |
clear
Signature
clear(): void;
matchAnyEvent
Search events logged since the last time matchEvents was called, looking for any of the given expected events.
Signature
matchAnyEvent(expectedEvents: Omit<ITelemetryBaseEvent, "category">[]): boolean;
Parameters
Parameter | Type | Description |
---|---|---|
expectedEvents | Omit<ITelemetryBaseEvent, "category">[] | events that are expected to appear in the recorded log. These event objects may be subsets of the logged events. Note: category is ommitted from the type because it's usually uninteresting and tedious to type. |
Returns
if any of the expected events is found.
Return type: boolean
matchEvents
Search events logged since the last time matchEvents was called, looking for the given expected events in order.
Signature
matchEvents(expectedEvents: Omit<ITelemetryBaseEvent, "category">[]): boolean;
Parameters
Parameter | Type | Description |
---|---|---|
expectedEvents | Omit<ITelemetryBaseEvent, "category">[] | events in order that are expected to appear in the recorded log. These event objects may be subsets of the logged events. Note: category is ommitted from the type because it's usually uninteresting and tedious to type. |
Returns
Return type: boolean
send
Signature
send(event: ITelemetryBaseEvent): void;
Parameters
Parameter | Type | Description |
---|---|---|
event | ITelemetryBaseEvent |