Skip to content

Commit cb73e7a

Browse files
authored
chore(event-spy): update event name & documentation (#18)
1 parent fbf50a7 commit cb73e7a

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export * from './create-config';
22
export * from './matchers';
3-
export * from './page/event-spy';
3+
export type { EventSpy } from './page/event-spy';
44
export * from './page/utils';
55
export * from './playwright-declarations';
66
export * from './playwright-page';

src/page/event-spy.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ export class EventSpy {
6060
}
6161

6262
/**
63+
* For internal use only.
64+
*
6365
* Initializes information required to spy on events.
64-
* The ionicOnEvent function is called in the context of the current page.
66+
* The stencilOnEvent function is called in the context of the current page.
6567
* This lets us respond to an event listener created within the page itself.
6668
*
6769
* @param page The Playwright test page object.
@@ -70,7 +72,7 @@ export const initPageEvents = async (page: E2EPage) => {
7072
page._e2eEventsIds = 0;
7173
page._e2eEvents = new Map();
7274

73-
await page.exposeFunction('ionicOnEvent', (id: number, ev: any) => {
75+
await page.exposeFunction('stencilOnEvent', (id: number, ev: any) => {
7476
const context = page._e2eEvents.get(id);
7577
if (context) {
7678
context.callback(ev);
@@ -79,6 +81,8 @@ export const initPageEvents = async (page: E2EPage) => {
7981
};
8082

8183
/**
84+
* For internal use only.
85+
*
8286
* Adds a new event listener in the current page context to updates
8387
* the _e2eEvents map when an event is fired.
8488
*
@@ -149,7 +153,7 @@ export const addE2EListener = async (
149153
};
150154

151155
elm.addEventListener(eventName as string, (ev: Event) => {
152-
(window as any).ionicOnEvent(id, (window as any).serializeStencilEvent(ev));
156+
(window as any).stencilOnEvent(id, (window as any).serializeStencilEvent(ev));
153157
});
154158
},
155159
[eventName, id],

src/playwright-declarations.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ export interface E2EPage extends Page {
5454
* [upstream issue](https://bugs.chromium.org/p/chromium/issues/detail?id=761295).
5555
*
5656
* Shortcut for main frame's [frame.goto(url[, options])](https://playwright.dev/docs/api/class-frame#frame-goto)
57-
* @param url URL to navigate page to. The url should include scheme, e.g. `https://`. When a `baseURL` via the context options was provided and the passed URL is a path, it gets merged via the
58-
* [`new URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor.
57+
* @param url URL to navigate page to. The url should include scheme, e.g. `https://`. When a `baseURL` via the context options was
58+
* provided and the passed URL is a path, it gets merged via the [`new URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor.
5959
*/
6060
goto: (url: string, options?: E2EPageOptions) => Promise<null | Response>;
6161

@@ -83,10 +83,8 @@ export interface E2EPage extends Page {
8383
*/
8484
waitForChanges: (timeoutMs?: number) => Promise<void>;
8585
/**
86-
* Creates a new EventSpy and listens
87-
* on the window for an event.
88-
* The test will timeout if the event
89-
* never fires.
86+
* Creates a new EventSpy and listens on the window for an event.
87+
* The test will timeout if the event never fires.
9088
*
9189
* Usage:
9290
* ```ts

0 commit comments

Comments
 (0)