sudovanilla-website/public/@shoelace-style/shoelace/cdn/internal/test/data-testid-helpers.d.ts

13 lines
782 B
TypeScript
Raw Normal View History

2024-05-13 22:34:06 -05:00
/**
* Allows you to find a DOM element based on the value of its `data-testid` attribute.
* This attribute can be used to decouple identifying dom elements for testing from
* styling (which is typically done via class selectors) or other ids which serve
* different purposes.
* See also https://kentcdodds.com/blog/making-your-ui-tests-resilient-to-change
* Inspired by https://testing-library.com/docs/queries/bytestid/
* @param {HTMLElement} container - A parent element of the DOM element to find
* @param {string} testId - The value of the `data-testid` attribute of the component to find.
* @returns The found element or null if there was no such element
*/
export declare const queryByTestId: <T extends Element>(container: HTMLElement, testId: string) => T | null;