chore(): sync with main

This commit is contained in:
Liam DeBeasi
2022-09-02 14:44:56 -04:00
403 changed files with 2107 additions and 2201 deletions

View File

@@ -1,7 +1,9 @@
import { toHaveReceivedEvent } from './toHaveReceivedEvent';
import { toHaveReceivedEventDetail } from './toHaveReceivedEventDetail';
import { toHaveReceivedEventTimes } from './toHaveReceivedEventTimes';
export const matchers = {
toHaveReceivedEvent,
toHaveReceivedEventDetail,
toHaveReceivedEventTimes,
};

View File

@@ -0,0 +1,33 @@
import type { EventSpy } from '../page/event-spy';
export function toHaveReceivedEventTimes(eventSpy: EventSpy, count: number) {
if (!eventSpy) {
return {
message: () => `toHaveReceivedEventTimes event spy is null`,
pass: false,
};
}
if (typeof (eventSpy as any).then === 'function') {
return {
message: () =>
`expected spy to have received event, but it was not resolved (did you forget an await operator?).`,
pass: false,
};
}
if (!eventSpy.eventName) {
return {
message: () => `toHaveReceivedEventTimes did not receive an event spy`,
pass: false,
};
}
const pass = eventSpy.length === count;
return {
message: () =>
`expected event "${eventSpy.eventName}" to have been called ${count} times, but it was called ${eventSpy.events.length} times`,
pass: pass,
};
}

View File

@@ -8,6 +8,11 @@ interface CustomMatchers<R = unknown> {
* @param eventDetail The expected detail of the event.
*/
toHaveReceivedEventDetail(eventDetail: any): R;
/**
* Will check how many times the event has been received.
*/
toHaveReceivedEventTimes(count: number): R;
}
declare namespace PlaywrightTest {