MCPcopy Create free account
hub / github.com/ionic-team/ionic-framework / testStack

Function testStack

packages/angular/test/base/e2e/utils/test-utils.ts:3–19  ·  view source on GitHub ↗
(page: Page, selector: string, expectedStack: string[])

Source from the content-addressed store, hash-verified

1import { expect, type Page, type Locator } from '@playwright/test';
2
3export async function testStack(page: Page, selector: string, expectedStack: string[]) {
4 const elements = page.locator(`${selector} > *`);
5 const count = await elements.count();
6
7 // Get the actual stack (tag names of child elements), filtering out non-components
8 const actualStack: string[] = [];
9 for (let i = 0; i < count; i++) {
10 const tagName = await elements.nth(i).evaluate(el => el.tagName.toLowerCase());
11 // Filter out non-component elements like 'slot', 'div', etc.
12 if (tagName.includes('-') || tagName.startsWith('app-') || tagName.startsWith('ion-')) {
13 actualStack.push(tagName);
14 }
15 }
16
17 // Compare the actual stack with the expected stack
18 expect(actualStack).toEqual(expectedStack);
19}
20
21export async function testLifeCycle(page: Page, selector: string, expectedCounts: Record<string, number>) {
22 await expect(page.locator(`${selector} #ngOnInit`)).toHaveText('1');

Callers 5

tabs.spec.tsFile · 0.90
routing.spec.tsFile · 0.90
testForwardFunction · 0.85
testRootFunction · 0.85
testBackFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected