UNPKG

@progress/kendo-e2e

Version:

Kendo UI end-to-end test utilities.

86 lines (85 loc) 3.71 kB
import { Browser } from "../selenium/browser"; /** * Crawler class that extends Browser to provide crawling functionality for testing links and components. */ export declare class Crawler extends Browser { /** * Scans the current page to find and log custom component tags. * * It extracts the component name from the URL path, constructs a CSS selector * using the `kendo-` prefix, and optionally checks for a singular form. * * Logs a warning if no matching elements are found or if a search fails. * * Special case: if the extracted name is "general", it uses the previous path segment instead. * * @param customTags - Optional array of custom CSS selectors to search for instead of URL-based extraction * * @example * ```typescript * // Use URL-based extraction (default behavior) * await crawler.crawlForTags(); * * // Use custom tags * await crawler.crawlForTags(['kendo-grid', 'kendo-chart']); * * // Use complex selectors * await crawler.crawlForTags(['kendo-grid .k-grid-header', 'kendo-button[type="submit"]']); * ``` */ crawlForTags(customTags?: string[]): Promise<void>; /** * Crawls all link elements (`<a href>`) on the current page, opens each link in a new tab, * checks for console errors, and optionally verifies component tags. * * Logs detailed information, including errors and successes, to a timestamped log file. * * Ensures browser cleanup by closing new tabs and returning to the original one after each link. * * @param options - Optional configuration object. * @param options.crawlForTags - If true, also runs `crawlForTags()` on each visited link. Defaults to `true`. * @param options.customTags - Optional array of custom CSS selectors to pass to `crawlForTags()`. * @param options.readySelector - CSS selector to wait for before checking console errors. * Defaults to `'body'`. Use a more specific selector (e.g. `'#app > *'`) to ensure the * page's JavaScript framework has finished rendering before logs are captured. * @param options.ignorePatterns - Error log entries matching any of these strings or regexes * will be silently ignored. Useful for known third-party errors that cannot be fixed. * @param options.ignoreUrls - Page URLs matching any of these strings or regexes will be * skipped entirely (all errors on that page are ignored). Useful for known-broken demos. * * @example * ```typescript * beforeAll(async () => { * crawler = new Crawler(); * await crawler.navigateTo('http://localhost:4200/'); * }); * * afterAll(async () => { * await crawler.close(); * }); * * it('crawl all links with URL-based tag detection', async () => { * await crawler.crawlForErrors(); * }); * * it('crawl all links with custom tags', async () => { * await crawler.crawlForErrors({ crawlForTags: true, customTags: ['kendo-grid', 'kendo-button'] }); * }); * * it('crawl all links without tag checking, wait for React to render, ignore known errors', async () => { * await crawler.crawlForErrors({ * crawlForTags: false, * readySelector: '#app > *', * ignorePatterns: ['React Router', /third-party-lib/], * }); * }); * ``` */ crawlForErrors(options?: { crawlForTags?: boolean; customTags?: string[]; readySelector?: string; ignorePatterns?: (string | RegExp)[]; ignoreUrls?: (string | RegExp)[]; }): Promise<void>; }