From 36ef06dfd674552eed045b4a1e311d5194f8ae18 Mon Sep 17 00:00:00 2001 From: Yiming Li Date: Thu, 24 Apr 2025 11:42:08 +0800 Subject: [PATCH 1/4] fix(testing-library): rollup dts files --- .changeset/rude-pears-open.md | 2 + .cspell/contributors.txt | 4 + cspell.jsonc | 1 + .../react/testing-library/api-extractor.json | 11 +- .../etc/react-lynx-testing-library.api.md | 1388 ++++++++++++++++- .../react/testing-library/types/entry.d.ts | 256 +++ .../react/testing-library/types/index.d.ts | 276 +--- .../test-environment/package.json | 16 + 8 files changed, 1693 insertions(+), 261 deletions(-) create mode 100644 .changeset/rude-pears-open.md create mode 100644 packages/react/testing-library/types/entry.d.ts diff --git a/.changeset/rude-pears-open.md b/.changeset/rude-pears-open.md new file mode 100644 index 0000000000..a845151cc8 --- /dev/null +++ b/.changeset/rude-pears-open.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/.cspell/contributors.txt b/.cspell/contributors.txt index 282e1489af..ce429baf4d 100644 --- a/.cspell/contributors.txt +++ b/.cspell/contributors.txt @@ -8,6 +8,10 @@ Zhiyuan ZhiyuanHong HongZhiyuan +Yiming +YimingLi +LiYiming + # Webpack Contributors Koppers sokra diff --git a/cspell.jsonc b/cspell.jsonc index 45de5e0786..c5e9efb517 100644 --- a/cspell.jsonc +++ b/cspell.jsonc @@ -152,6 +152,7 @@ "packages/react/types/*.d.ts", "packages/tools/css-serializer/**", "packages/web-platform/**", + "packages/react/testing-library/etc/react-lynx-testing-library.api.md", // Output "dist", "lib", diff --git a/packages/react/testing-library/api-extractor.json b/packages/react/testing-library/api-extractor.json index 2d2d66ca84..ec1eb75bdc 100644 --- a/packages/react/testing-library/api-extractor.json +++ b/packages/react/testing-library/api-extractor.json @@ -4,7 +4,7 @@ { "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", "extends": "../../../api-extractor.json", - "mainEntryPointFilePath": "/types/index.d.ts", + "mainEntryPointFilePath": "/types/entry.d.ts", "compiler": { "overrideTsconfig": { "compilerOptions": { @@ -12,4 +12,13 @@ }, }, }, + "bundledPackages": [ + "@testing-library/dom", + "@lynx-js/test-environment", + ], + "dtsRollup": { + "enabled": true, + "untrimmedFilePath": "", + "publicTrimmedFilePath": "/dist/index.d.ts", + }, } diff --git a/packages/react/testing-library/etc/react-lynx-testing-library.api.md b/packages/react/testing-library/etc/react-lynx-testing-library.api.md index 4b6e4c9866..2d8b105d9a 100644 --- a/packages/react/testing-library/etc/react-lynx-testing-library.api.md +++ b/packages/react/testing-library/etc/react-lynx-testing-library.api.md @@ -4,16 +4,1293 @@ ```ts -import { BoundFunction } from '@testing-library/dom'; +import { ARIARole } from 'aria-query'; import { ComponentChild } from 'preact'; import { ComponentType } from 'preact'; -import { LynxElement } from '@lynx-js/test-environment'; -import { Queries } from '@testing-library/dom'; -import { queries } from '@testing-library/dom'; +import { OptionsReceived } from 'pretty-format'; +import * as prettyFormat from 'pretty-format'; + +// Warning: (ae-missing-release-tag) "AllByAttribute" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type AllByAttribute = ( +attribute: string, +container: HTMLElement, +id: Matcher, +options?: MatcherOptions, +) => HTMLElement[] + +// Warning: (ae-missing-release-tag) "AllByBoundAttribute" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type AllByBoundAttribute = ( +container: HTMLElement, +id: Matcher, +options?: MatcherOptions, +) => T[] + +// Warning: (ae-missing-release-tag) "AllByRole" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type AllByRole = ( +container: HTMLElement, +role: ByRoleMatcher, +options?: ByRoleOptions, +) => T[] + +// Warning: (ae-missing-release-tag) "AllByText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type AllByText = ( +container: HTMLElement, +id: Matcher, +options?: SelectorMatcherOptions, +) => T[] + +// Warning: (ae-missing-release-tag) "BoundFunction" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type BoundFunction = T extends ( +container: HTMLElement, +...args: infer P +) => infer R +? (...args: P) => R +: never + +// Warning: (ae-missing-release-tag) "BoundFunctions" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type BoundFunctions = Q extends typeof queries +? { + getByLabelText( + ...args: Parameters>> + ): ReturnType> + getAllByLabelText( + ...args: Parameters>> + ): ReturnType> + queryByLabelText( + ...args: Parameters>> + ): ReturnType> + queryAllByLabelText( + ...args: Parameters>> + ): ReturnType> + findByLabelText( + ...args: Parameters>> + ): ReturnType> + findAllByLabelText( + ...args: Parameters>> + ): ReturnType> + getByPlaceholderText( + ...args: Parameters>> + ): ReturnType> + getAllByPlaceholderText( + ...args: Parameters>> + ): ReturnType> + queryByPlaceholderText( + ...args: Parameters>> + ): ReturnType> + queryAllByPlaceholderText( + ...args: Parameters>> + ): ReturnType> + findByPlaceholderText( + ...args: Parameters>> + ): ReturnType> + findAllByPlaceholderText( + ...args: Parameters>> + ): ReturnType> + getByText( + ...args: Parameters>> + ): ReturnType> + getAllByText( + ...args: Parameters>> + ): ReturnType> + queryByText( + ...args: Parameters>> + ): ReturnType> + queryAllByText( + ...args: Parameters>> + ): ReturnType> + findByText( + ...args: Parameters>> + ): ReturnType> + findAllByText( + ...args: Parameters>> + ): ReturnType> + getByAltText( + ...args: Parameters>> + ): ReturnType> + getAllByAltText( + ...args: Parameters>> + ): ReturnType> + queryByAltText( + ...args: Parameters>> + ): ReturnType> + queryAllByAltText( + ...args: Parameters>> + ): ReturnType> + findByAltText( + ...args: Parameters>> + ): ReturnType> + findAllByAltText( + ...args: Parameters>> + ): ReturnType> + getByTitle( + ...args: Parameters>> + ): ReturnType> + getAllByTitle( + ...args: Parameters>> + ): ReturnType> + queryByTitle( + ...args: Parameters>> + ): ReturnType> + queryAllByTitle( + ...args: Parameters>> + ): ReturnType> + findByTitle( + ...args: Parameters>> + ): ReturnType> + findAllByTitle( + ...args: Parameters>> + ): ReturnType> + getByDisplayValue( + ...args: Parameters>> + ): ReturnType> + getAllByDisplayValue( + ...args: Parameters>> + ): ReturnType> + queryByDisplayValue( + ...args: Parameters>> + ): ReturnType> + queryAllByDisplayValue( + ...args: Parameters>> + ): ReturnType> + findByDisplayValue( + ...args: Parameters>> + ): ReturnType> + findAllByDisplayValue( + ...args: Parameters>> + ): ReturnType> + getByRole( + ...args: Parameters>> + ): ReturnType> + getAllByRole( + ...args: Parameters>> + ): ReturnType> + queryByRole( + ...args: Parameters>> + ): ReturnType> + queryAllByRole( + ...args: Parameters>> + ): ReturnType> + findByRole( + ...args: Parameters>> + ): ReturnType> + findAllByRole( + ...args: Parameters>> + ): ReturnType> + getByTestId( + ...args: Parameters>> + ): ReturnType> + getAllByTestId( + ...args: Parameters>> + ): ReturnType> + queryByTestId( + ...args: Parameters>> + ): ReturnType> + queryAllByTestId( + ...args: Parameters>> + ): ReturnType> + findByTestId( + ...args: Parameters>> + ): ReturnType> + findAllByTestId( + ...args: Parameters>> + ): ReturnType> +} & { + [P in keyof Q]: BoundFunction +} +: { + [P in keyof Q]: BoundFunction +} + +// Warning: (ae-missing-release-tag) "buildQueries" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function buildQueries( +queryAllBy: GetAllBy, +getMultipleError: GetErrorFunction, +getMissingError: GetErrorFunction, +): BuiltQueryMethods + +// Warning: (ae-missing-release-tag) "BuiltQueryMethods" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type BuiltQueryMethods = [ +QueryBy, +GetAllBy, +GetBy, +FindAllBy, +FindBy, +] + +// Warning: (ae-missing-release-tag) "ByRoleMatcher" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type ByRoleMatcher = ARIARole | (string & {}) + +// Warning: (ae-missing-release-tag) "ByRoleOptions" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface ByRoleOptions { + busy?: boolean + checked?: boolean + current?: boolean | string + description?: + | RegExp + | string + | ((accessibleDescription: string, element: Element) => boolean) + expanded?: boolean + hidden?: boolean + level?: number + name?: + | RegExp + | string + | ((accessibleName: string, element: Element) => boolean) + pressed?: boolean + // Warning: (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag + // Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@" + queryFallbacks?: boolean + selected?: boolean + suggest?: boolean + // (undocumented) + value?: { + now?: number + min?: number + max?: number + text?: Matcher + } +} // @public export function cleanup(): void; +// Warning: (ae-missing-release-tag) "computeHeadingLevel" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function computeHeadingLevel(element: Element): number | undefined + +// Warning: (ae-missing-release-tag) "Config" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface Config { + // (undocumented) + asyncUtilTimeout: number + // (undocumented) + asyncWrapper(cb: (...args: any[]) => any): Promise + // (undocumented) + computedStyleSupportsPseudoElements: boolean + // (undocumented) + defaultHidden: boolean + defaultIgnore: string + // (undocumented) + eventWrapper(cb: (...args: any[]) => any): void + // (undocumented) + getElementError: (message: string | null, container: Element) => Error + // (undocumented) + showOriginalStackTrace: boolean + // (undocumented) + testIdAttribute: string + // (undocumented) + throwSuggestions: boolean + // Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen + unstable_advanceTimersWrapper(cb: (...args: unknown[]) => unknown): unknown +} + +// Warning: (ae-missing-release-tag) "ConfigFn" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface ConfigFn { + // (undocumented) + (existingConfig: Config): Partial +} + +// Warning: (ae-missing-release-tag) "configure" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function configure(configDelta: ConfigFn | Partial): void + +// Warning: (ae-missing-release-tag) "createEvent" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export const createEvent: CreateObject & CreateFunction; + +// Warning: (ae-missing-release-tag) "CreateFunction" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type CreateFunction = ( +eventName: string, +node: Document | Element | Window | Node, +init?: {}, +options?: {EventType?: string; defaultInit?: {}}, +) => Event + +// Warning: (ae-missing-release-tag) "CreateObject" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type CreateObject = { + [K in EventType]: ( + element: Document | Element | Window | Node, + options?: {}, + ) => Event +} + +// Warning: (ae-missing-release-tag) "DefaultNormalizerOptions" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface DefaultNormalizerOptions { + // (undocumented) + collapseWhitespace?: boolean + // (undocumented) + trim?: boolean +} + +// Warning: (ae-missing-release-tag) "EventType" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type EventType = +| 'copy' +| 'cut' +| 'paste' +| 'compositionEnd' +| 'compositionStart' +| 'compositionUpdate' +| 'keyDown' +| 'keyPress' +| 'keyUp' +| 'focus' +| 'blur' +| 'focusIn' +| 'focusOut' +| 'change' +| 'input' +| 'invalid' +| 'submit' +| 'reset' +| 'click' +| 'contextMenu' +| 'dblClick' +| 'drag' +| 'dragEnd' +| 'dragEnter' +| 'dragExit' +| 'dragLeave' +| 'dragOver' +| 'dragStart' +| 'drop' +| 'mouseDown' +| 'mouseEnter' +| 'mouseLeave' +| 'mouseMove' +| 'mouseOut' +| 'mouseOver' +| 'mouseUp' +| 'popState' +| 'select' +| 'touchCancel' +| 'touchEnd' +| 'touchMove' +| 'touchStart' +| 'resize' +| 'scroll' +| 'wheel' +| 'abort' +| 'canPlay' +| 'canPlayThrough' +| 'durationChange' +| 'emptied' +| 'encrypted' +| 'ended' +| 'loadedData' +| 'loadedMetadata' +| 'loadStart' +| 'pause' +| 'play' +| 'playing' +| 'progress' +| 'rateChange' +| 'seeked' +| 'seeking' +| 'stalled' +| 'suspend' +| 'timeUpdate' +| 'volumeChange' +| 'waiting' +| 'load' +| 'error' +| 'animationStart' +| 'animationEnd' +| 'animationIteration' +| 'transitionCancel' +| 'transitionEnd' +| 'transitionRun' +| 'transitionStart' +| 'doubleClick' +| 'pointerOver' +| 'pointerEnter' +| 'pointerDown' +| 'pointerMove' +| 'pointerUp' +| 'pointerCancel' +| 'pointerOut' +| 'pointerLeave' +| 'gotPointerCapture' +| 'lostPointerCapture' +| 'offline' +| 'online' +| 'pageHide' +| 'pageShow' + +// Warning: (ae-missing-release-tag) "FindAllBy" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type FindAllBy = QueryMethod< +[Arguments[0], Arguments[1]?, waitForOptions?], +Promise +> + +// Warning: (ae-missing-release-tag) "findAllByAltText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function findAllByAltText( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "FindAllByBoundAttribute" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type FindAllByBoundAttribute = ( +container: HTMLElement, +id: Matcher, +options?: MatcherOptions, +waitForElementOptions?: waitForOptions, +) => Promise + +// Warning: (ae-missing-release-tag) "findAllByDisplayValue" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function findAllByDisplayValue( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "findAllByLabelText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function findAllByLabelText( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "findAllByPlaceholderText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function findAllByPlaceholderText( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "FindAllByRole" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type FindAllByRole = ( +container: HTMLElement, +role: ByRoleMatcher, +options?: ByRoleOptions, +waitForElementOptions?: waitForOptions, +) => Promise + +// Warning: (ae-missing-release-tag) "findAllByRole" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function findAllByRole( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "findAllByTestId" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function findAllByTestId( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "FindAllByText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type FindAllByText = ( +container: HTMLElement, +id: Matcher, +options?: SelectorMatcherOptions, +waitForElementOptions?: waitForOptions, +) => Promise + +// Warning: (ae-missing-release-tag) "findAllByText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function findAllByText( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "findAllByTitle" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function findAllByTitle( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "FindBy" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type FindBy = QueryMethod< +[Arguments[0], Arguments[1]?, waitForOptions?], +Promise +> + +// Warning: (ae-missing-release-tag) "findByAltText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function findByAltText( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "FindByBoundAttribute" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type FindByBoundAttribute = ( +container: HTMLElement, +id: Matcher, +options?: MatcherOptions, +waitForElementOptions?: waitForOptions, +) => Promise + +// Warning: (ae-missing-release-tag) "findByDisplayValue" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function findByDisplayValue( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "findByLabelText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function findByLabelText( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "findByPlaceholderText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function findByPlaceholderText( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "FindByRole" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type FindByRole = ( +container: HTMLElement, +role: ByRoleMatcher, +options?: ByRoleOptions, +waitForElementOptions?: waitForOptions, +) => Promise + +// Warning: (ae-missing-release-tag) "findByRole" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function findByRole( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "findByTestId" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function findByTestId( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "FindByText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type FindByText = ( +container: HTMLElement, +id: Matcher, +options?: SelectorMatcherOptions, +waitForElementOptions?: waitForOptions, +) => Promise + +// Warning: (ae-missing-release-tag) "findByText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function findByText( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "findByTitle" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function findByTitle( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "fireEvent" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export const fireEvent: FireFunction & FireObject; + +// Warning: (ae-missing-release-tag) "FireFunction" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type FireFunction = ( +element: Document | Element | Window | Node, +event: Event, +) => boolean + +// Warning: (ae-missing-release-tag) "FireObject" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type FireObject = { + [K in EventType]: ( + element: Document | Element | Window | Node, + options?: {}, + ) => boolean +} + +// Warning: (ae-missing-release-tag) "GetAllBy" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type GetAllBy = QueryMethod< +Arguments, +HTMLElement[] +> + +// Warning: (ae-missing-release-tag) "getAllByAltText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getAllByAltText( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "getAllByDisplayValue" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getAllByDisplayValue( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "getAllByLabelText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getAllByLabelText( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "getAllByPlaceholderText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getAllByPlaceholderText( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "getAllByRole" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getAllByRole( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "getAllByTestId" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getAllByTestId( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "getAllByText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getAllByText( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "getAllByTitle" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getAllByTitle( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "GetBy" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type GetBy = QueryMethod + +// Warning: (ae-missing-release-tag) "getByAltText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getByAltText( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "GetByBoundAttribute" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type GetByBoundAttribute = ( +container: HTMLElement, +id: Matcher, +options?: MatcherOptions, +) => T + +// Warning: (ae-missing-release-tag) "getByDisplayValue" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getByDisplayValue( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "getByLabelText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getByLabelText( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "getByPlaceholderText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getByPlaceholderText( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "GetByRole" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type GetByRole = ( +container: HTMLElement, +role: ByRoleMatcher, +options?: ByRoleOptions, +) => T + +// Warning: (ae-missing-release-tag) "getByRole" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getByRole( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "getByTestId" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getByTestId( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "GetByText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type GetByText = ( +container: HTMLElement, +id: Matcher, +options?: SelectorMatcherOptions, +) => T + +// Warning: (ae-missing-release-tag) "getByText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getByText( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "getByTitle" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getByTitle( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "getConfig" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getConfig(): Config + +// Warning: (ae-missing-release-tag) "getDefaultNormalizer" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getDefaultNormalizer( +options?: DefaultNormalizerOptions, +): NormalizerFn + +// Warning: (ae-missing-release-tag) "getElementError" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getElementError( +message: string | null, +container: HTMLElement, +): Error + +// Warning: (ae-missing-release-tag) "GetErrorFunction" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type GetErrorFunction = ( +c: Element | null, +...args: Arguments +) => string + +// Warning: (ae-missing-release-tag) "getNodeText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getNodeText(node: HTMLElement): string + +// Warning: (ae-missing-release-tag) "getQueriesForElement" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getQueriesForElement< +QueriesToBind extends Queries = typeof queries, +// Extra type parameter required for reassignment. +T extends QueriesToBind = QueriesToBind, +>(element: HTMLElement, queriesToBind?: T): BoundFunctions + +// Warning: (ae-missing-release-tag) "getRoles" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getRoles(container: HTMLElement): { + [index: string]: HTMLElement[] +} + +// Warning: (ae-missing-release-tag) "getSuggestedQuery" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getSuggestedQuery( +element: HTMLElement, +variant?: Variant, +method?: Method, +): Suggestion | undefined + +// Warning: (ae-missing-release-tag) "isInaccessible" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function isInaccessible(element: Element): boolean + +// Warning: (ae-missing-release-tag) "logDOM" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function logDOM( +dom?: Element | HTMLDocument, +maxLength?: number, +options?: PrettyDOMOptions, +): void + +// Warning: (ae-missing-release-tag) "logRoles" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function logRoles( +container: HTMLElement, +options?: LogRolesOptions, +): string + +// Warning: (ae-missing-release-tag) "LogRolesOptions" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface LogRolesOptions { + // (undocumented) + hidden?: boolean +} + +// Warning: (ae-missing-release-tag) "Match" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type Match = ( +textToMatch: string, +node: HTMLElement | null, +matcher: Matcher, +options?: MatcherOptions, +) => boolean + +// Warning: (ae-missing-release-tag) "Matcher" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type Matcher = MatcherFunction | RegExp | number | string + +// Warning: (ae-missing-release-tag) "MatcherFunction" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type MatcherFunction = ( +content: string, +element: Element | null, +) => boolean + +// Warning: (ae-missing-release-tag) "MatcherOptions" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface MatcherOptions { + collapseWhitespace?: boolean + // (undocumented) + exact?: boolean + // (undocumented) + normalizer?: NormalizerFn + suggest?: boolean + trim?: boolean +} + +// Warning: (ae-missing-release-tag) "Method" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type Method = +| 'AltText' +| 'alttext' +| 'DisplayValue' +| 'displayvalue' +| 'LabelText' +| 'labeltext' +| 'PlaceholderText' +| 'placeholdertext' +| 'Role' +| 'role' +| 'TestId' +| 'testid' +| 'Text' +| 'text' +| 'Title' +| 'title' + +// Warning: (ae-missing-release-tag) "NormalizerFn" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type NormalizerFn = (text: string) => string + +// Warning: (ae-missing-release-tag) "NormalizerOptions" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface NormalizerOptions extends DefaultNormalizerOptions { + // (undocumented) + normalizer?: NormalizerFn +} + +// Warning: (ae-missing-release-tag) "prettyDOM" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function prettyDOM( +dom?: Element | HTMLDocument, +maxLength?: number, +options?: PrettyDOMOptions, +): string | false + +// Warning: (ae-missing-release-tag) "PrettyDOMOptions" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface PrettyDOMOptions extends prettyFormat.OptionsReceived { + filterNode?: (node: Node) => boolean +} + +export { prettyFormat } + +// Warning: (ae-missing-release-tag) "Queries" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface Queries { + // (undocumented) + [T: string]: Query +} + +declare namespace queries { + export { + getByLabelText, + getAllByLabelText, + queryByLabelText, + queryAllByLabelText, + findByLabelText, + findAllByLabelText, + getByPlaceholderText, + getAllByPlaceholderText, + queryByPlaceholderText, + queryAllByPlaceholderText, + findByPlaceholderText, + findAllByPlaceholderText, + getByText, + getAllByText, + queryByText, + queryAllByText, + findByText, + findAllByText, + getByAltText, + getAllByAltText, + queryByAltText, + queryAllByAltText, + findByAltText, + findAllByAltText, + getByTitle, + getAllByTitle, + queryByTitle, + queryAllByTitle, + findByTitle, + findAllByTitle, + getByDisplayValue, + getAllByDisplayValue, + queryByDisplayValue, + queryAllByDisplayValue, + findByDisplayValue, + findAllByDisplayValue, + getByRole, + getAllByRole, + queryByRole, + queryAllByRole, + findByRole, + findAllByRole, + getByTestId, + getAllByTestId, + queryByTestId, + queryAllByTestId, + findByTestId, + findAllByTestId, + QueryByBoundAttribute, + AllByBoundAttribute, + FindAllByBoundAttribute, + GetByBoundAttribute, + FindByBoundAttribute, + QueryByText, + AllByText, + FindAllByText, + GetByText, + FindByText, + ByRoleOptions, + AllByRole, + GetByRole, + QueryByRole, + FindByRole, + FindAllByRole + } +} +export { queries } + +// Warning: (ae-missing-release-tag) "Query" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type Query = ( +container: HTMLElement, +...args: any[] +) => +| Error +| HTMLElement +| HTMLElement[] +| Promise +| Promise +| null + +// Warning: (ae-missing-release-tag) "queryAllByAltText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function queryAllByAltText( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "queryAllByAttribute" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export const queryAllByAttribute: AllByAttribute; + +// Warning: (ae-missing-release-tag) "queryAllByDisplayValue" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function queryAllByDisplayValue( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "queryAllByLabelText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function queryAllByLabelText( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "queryAllByPlaceholderText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function queryAllByPlaceholderText( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "queryAllByRole" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function queryAllByRole( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "queryAllByTestId" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function queryAllByTestId( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "queryAllByText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function queryAllByText( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "queryAllByTitle" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function queryAllByTitle( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "QueryArgs" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type QueryArgs = [string, QueryOptions?] + +// Warning: (ae-missing-release-tag) "QueryBy" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type QueryBy = QueryMethod< +Arguments, +HTMLElement | null +> + +// Warning: (ae-missing-release-tag) "queryByAltText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function queryByAltText( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "QueryByAttribute" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type QueryByAttribute = ( +attribute: string, +container: HTMLElement, +id: Matcher, +options?: MatcherOptions, +) => HTMLElement | null + +// Warning: (ae-missing-release-tag) "queryByAttribute" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export const queryByAttribute: QueryByAttribute; + +// Warning: (ae-missing-release-tag) "QueryByBoundAttribute" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type QueryByBoundAttribute = ( +container: HTMLElement, +id: Matcher, +options?: MatcherOptions, +) => T | null + +// Warning: (ae-missing-release-tag) "queryByDisplayValue" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function queryByDisplayValue( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "queryByLabelText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function queryByLabelText( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "queryByPlaceholderText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function queryByPlaceholderText( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "QueryByRole" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type QueryByRole = ( +container: HTMLElement, +role: ByRoleMatcher, +options?: ByRoleOptions, +) => T | null + +// Warning: (ae-missing-release-tag) "queryByRole" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function queryByRole( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "queryByTestId" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function queryByTestId( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "QueryByText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type QueryByText = ( +container: HTMLElement, +id: Matcher, +options?: SelectorMatcherOptions, +) => T | null + +// Warning: (ae-missing-release-tag) "queryByText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function queryByText( +...args: Parameters> +): ReturnType> + +// Warning: (ae-missing-release-tag) "queryByTitle" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function queryByTitle( +...args: Parameters> +): ReturnType> + +declare namespace queryHelpers { + export { + getElementError, + buildQueries, + WithSuggest, + GetErrorFunction, + SelectorMatcherOptions, + QueryByAttribute, + AllByAttribute, + queryByAttribute, + queryAllByAttribute, + QueryMethod, + QueryBy, + GetAllBy, + FindAllBy, + GetBy, + FindBy, + BuiltQueryMethods + } +} +export { queryHelpers } + +// Warning: (ae-missing-release-tag) "QueryMethod" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export type QueryMethod = ( +container: HTMLElement, +...args: Arguments +) => Return + +// Warning: (ae-missing-release-tag) "QueryOptions" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface QueryOptions { + // (undocumented) + [key: string]: RegExp | boolean +} + // @public export function render( ui: ComponentChild, @@ -56,10 +1333,111 @@ export type RenderResult = { unmount: () => boolean; } & { [P in keyof Q]: BoundFunction }; +// Warning: (ae-missing-release-tag) "Screen" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +type Screen_2 = BoundFunctions & { + debug: ( + element?: Array | Element | HTMLDocument, + maxLength?: number, + options?: OptionsReceived, + ) => void + logTestingPlaygroundURL: (element?: Element | HTMLDocument) => string +} +export { Screen_2 as Screen } + +// Warning: (ae-missing-release-tag) "screen" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +const screen_2: Screen_2; +export { screen_2 as screen } + +// Warning: (ae-missing-release-tag) "SelectorMatcherOptions" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface SelectorMatcherOptions extends MatcherOptions { + // (undocumented) + ignore?: boolean | string + // (undocumented) + selector?: string +} + +// Warning: (ae-missing-release-tag) "Suggestion" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface Suggestion { + // (undocumented) + queryArgs: QueryArgs + // (undocumented) + queryMethod: string + // (undocumented) + queryName: string + // (undocumented) + toString(): string + // (undocumented) + variant: string + // (undocumented) + warning?: string +} + +// Warning: (ae-missing-release-tag) "Variant" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type Variant = +| 'find' +| 'findAll' +| 'get' +| 'getAll' +| 'query' +| 'queryAll' + +// Warning: (ae-missing-release-tag) "waitFor" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function waitFor( +callback: () => Promise | T, +options?: waitForOptions, +): Promise + +// Warning: (ae-missing-release-tag) "waitForElementToBeRemoved" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function waitForElementToBeRemoved( +callback: T | (() => T), +options?: waitForOptions, +): Promise + +// Warning: (ae-missing-release-tag) "waitForOptions" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface waitForOptions { + // (undocumented) + container?: HTMLElement + // (undocumented) + interval?: number + // (undocumented) + mutationObserverOptions?: MutationObserverInit + // (undocumented) + onTimeout?: (error: Error) => Error + // (undocumented) + timeout?: number +} + // @public export function waitSchedule(): Promise; +// Warning: (ae-missing-release-tag) "within" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export const within: typeof getQueriesForElement; + +// Warning: (ae-missing-release-tag) "WithSuggest" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type WithSuggest = {suggest?: boolean} -export * from "@testing-library/dom"; +// Warnings were encountered during analysis: +// +// types/entry.d.ts:214:29 - (ae-forgotten-export) The symbol "LynxElement" needs to be exported by the entry point entry.d.ts ``` diff --git a/packages/react/testing-library/types/entry.d.ts b/packages/react/testing-library/types/entry.d.ts new file mode 100644 index 0000000000..83030587c6 --- /dev/null +++ b/packages/react/testing-library/types/entry.d.ts @@ -0,0 +1,256 @@ +/** + * @packageDocumentation + * + * ReactLynx Testing Library is a simple and complete ReactLynx + * unit testing library that encourages good testing practices. + * + * Inspired by {@link https://testing-library.com/docs/react-testing-library/intro | React Testing Library} and {@link https://github.com/jsdom/jsdom | jsdom}. + */ + +import { queries, Queries, BoundFunction } from '@testing-library/dom'; +import { LynxElement, type ElementTree, type LynxEnv } from '@lynx-js/test-environment'; +import { ComponentChild, ComponentType } from 'preact'; +export * from '@testing-library/dom'; + +/** + * The options for {@link render}. + * + * @public + */ +export interface RenderOptions { + /** + * Queries to bind. Overrides the default set from DOM Testing Library unless merged. + * + * @example + * + * ```ts + * // Example, a function to traverse table contents + * import * as tableQueries from 'my-table-query-library' + * import { queries } from '@lynx-js/react/testing-library' + * + * const { getByRowColumn, getByText } = render(, { + * queries: {...queries, ...tableQueries}, + * }) + * + * ``` + */ + queries?: Q; + /** + * Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating + * reusable custom render functions for common data providers. See setup for examples. + * + * @example + * + * ```ts + * import { render } from '@lynx-js/react/testing-library' + * import { ThemeProvider } from 'my-ui-lib' + * import { TranslationProvider } from 'my-i18n-lib' + * import defaultStrings from 'i18n/en-x-default' + * + * const AllTheProviders = ({children}) => { + * return ( + * + * + * {children} + * + * + * ) + * } + * + * const customRender = (ui, options) => + * render(ui, { wrapper: AllTheProviders, ...options }) + * + * // re-export everything + * export * from '@lynx-js/react/testing-library' + * + * // override render method + * export { customRender as render } + * ``` + */ + wrapper?: ComponentChild; + /** + * Render your component in the main thread or not. + * + * It is recommended to use this option only when you need to test the {@link https://lynxjs.org/zh/guide/interaction/ifr.html | IFR} behavior. + * + * @defaultValue false + */ + enableMainThread?: boolean; + /** + * Render your component in the background thread or not. + * + * Note that all user code in the top level will be executed in the background thread by default. (eg. `__BACKGROUND__` is `true` in the top level) + * + * @defaultValue true + */ + enableBackgroundThread?: boolean; +} + +/** + * The result of {@link render} + * + * @public + */ +export type RenderResult = { + container: LynxElement; + rerender: (ui: ComponentChild) => void; + unmount: () => boolean; +} & { [P in keyof Q]: BoundFunction }; + +/** + * Render into the page. It should be used with cleanup. + * + * @example + * + * ```ts + * import { render} from '@lynx-js/react/testing-library' + * + * const WrapperComponent = ({ children }) => ( + * {children} + * ); + * const Comp = () => { + * return ; + * }; + * const { container, getByTestId } = render(, { + * wrapper: WrapperComponent, + * }); + * expect(getByTestId('wrapper')).toBeInTheDocument(); + * expect(container.firstChild).toMatchInlineSnapshot(` + * + * + * + * `); + * ``` + * + * @public + */ +export function render( + ui: ComponentChild, + options?: RenderOptions, +): RenderResult; +/** + * Cleanup elements rendered to the page and Preact trees that were mounted with render. + * + * @public + */ +export function cleanup(): void; + +/** + * The result of {@link renderHook} + * + * @public + */ + +export interface RenderHookResult { + /** + * Triggers a re-render. The props will be passed to your renderHook callback. + */ + rerender: (props?: Props) => void; + /** + * This is a stable reference to the latest value returned by your renderHook + * callback + */ + result: { + /** + * The value returned by your renderHook callback + */ + current: Result; + }; + /** + * Unmounts the test component. This is useful for when you need to test + * any cleanup your useEffects have. + */ + unmount: () => void; +} + +/** + * The options for {@link renderHook} + * + * @public + */ +export interface RenderHookOptions { + /** + * The argument passed to the renderHook callback. Can be useful if you plan + * to use the rerender utility to change the values passed to your hook. + */ + initialProps?: Props; + /** + * Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating + * reusable custom render functions for common data providers. See setup for examples. + * + * @example + * + * ```ts + * import { renderHook } from '@lynx-js/react/testing-library' + * import { ThemeProvider } from 'my-ui-lib' + * import { TranslationProvider } from 'my-i18n-lib' + * import defaultStrings from 'i18n/en-x-default' + * + * const AllTheProviders = ({children}) => { + * return ( + * + * + * {children} + * + * + * ) + * } + * + * const customRenderHook = (ui, options) => + * renderHook(ui, { wrapper: AllTheProviders, ...options }) + * + * // re-export everything + * export * from '@lynx-js/react/testing-library' + * + * // override renderHook method + * export { customRender as renderHook } + * ``` + */ + wrapper?: ComponentType<{ children: LynxElement }>; +} + +/** + * Allows you to render a hook within a test React component without having to + * create that component yourself. + * + * @example + * + * ```ts + * import { renderHook } from '@lynx-js/react/testing-library' + * + * const Context = createContext('default'); + * function Wrapper({ children }) { + * return {children}; + * } + * const { result } = renderHook( + * () => { + * return useContext(Context); + * }, + * { + * wrapper: Wrapper, + * }, + * ); + * + * expect(result.current).toEqual('provided'); + * ``` + * + * @public + */ +export function renderHook( + render: (initialProps: Props) => Result, + options?: RenderHookOptions, +): RenderHookResult; + +/** + * Wait for the next event loop. + * + * It will be useful when you want to wait for the next event loop to finish. + * + * @public + */ +export function waitSchedule(): Promise; diff --git a/packages/react/testing-library/types/index.d.ts b/packages/react/testing-library/types/index.d.ts index 9e7ee2b7ac..50939385bc 100644 --- a/packages/react/testing-library/types/index.d.ts +++ b/packages/react/testing-library/types/index.d.ts @@ -1,256 +1,22 @@ -/** - * @packageDocumentation - * - * ReactLynx Testing Library is a simple and complete ReactLynx - * unit testing library that encourages good testing practices. - * - * Inspired by {@link https://testing-library.com/docs/react-testing-library/intro | React Testing Library} and {@link https://github.com/jsdom/jsdom | jsdom}. - */ - -import { queries, Queries, BoundFunction } from '@testing-library/dom'; -import { LynxElement } from '@lynx-js/test-environment'; -import { ComponentChild, ComponentType } from 'preact'; -export * from '@testing-library/dom'; - -/** - * The options for {@link render}. - * - * @public - */ -export interface RenderOptions { - /** - * Queries to bind. Overrides the default set from DOM Testing Library unless merged. - * - * @example - * - * ```ts - * // Example, a function to traverse table contents - * import * as tableQueries from 'my-table-query-library' - * import { queries } from '@lynx-js/react/testing-library' - * - * const { getByRowColumn, getByText } = render(, { - * queries: {...queries, ...tableQueries}, - * }) - * - * ``` - */ - queries?: Q; - /** - * Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating - * reusable custom render functions for common data providers. See setup for examples. - * - * @example - * - * ```ts - * import { render } from '@lynx-js/react/testing-library' - * import { ThemeProvider } from 'my-ui-lib' - * import { TranslationProvider } from 'my-i18n-lib' - * import defaultStrings from 'i18n/en-x-default' - * - * const AllTheProviders = ({children}) => { - * return ( - * - * - * {children} - * - * - * ) - * } - * - * const customRender = (ui, options) => - * render(ui, { wrapper: AllTheProviders, ...options }) - * - * // re-export everything - * export * from '@lynx-js/react/testing-library' - * - * // override render method - * export { customRender as render } - * ``` - */ - wrapper?: ComponentChild; - /** - * Render your component in the main thread or not. - * - * It is recommended to use this option only when you need to test the {@link https://lynxjs.org/zh/guide/interaction/ifr.html | IFR} behavior. - * - * @defaultValue false - */ - enableMainThread?: boolean; - /** - * Render your component in the background thread or not. - * - * Note that all user code in the top level will be executed in the background thread by default. (eg. `__BACKGROUND__` is `true` in the top level) - * - * @defaultValue true - */ - enableBackgroundThread?: boolean; +// @ts-nocheck +export * from '../dist/index.d.ts'; + +declare global { + var lynxEnv: LynxEnv; + var elementTree: ElementTree; + var __JS__: boolean; + var __LEPUS__: boolean; + var __BACKGROUND__: boolean; + var __MAIN_THREAD__: boolean; + + namespace lynxCoreInject { + var tt: any; + } + + function onInjectBackgroundThreadGlobals(globals: any): void; + function onInjectMainThreadGlobals(globals: any): void; + function onSwitchedToBackgroundThread(): void; + function onSwitchedToMainThread(): void; + function onResetLynxEnv(): void; + function onInitWorkletRuntime(): void; } - -/** - * The result of {@link render} - * - * @public - */ -export type RenderResult = { - container: LynxElement; - rerender: (ui: ComponentChild) => void; - unmount: () => boolean; -} & { [P in keyof Q]: BoundFunction }; - -/** - * Render into the page. It should be used with cleanup. - * - * @example - * - * ```ts - * import { render} from '@lynx-js/react/testing-library' - * - * const WrapperComponent = ({ children }) => ( - * {children} - * ); - * const Comp = () => { - * return ; - * }; - * const { container, getByTestId } = render(, { - * wrapper: WrapperComponent, - * }); - * expect(getByTestId('wrapper')).toBeInTheDocument(); - * expect(container.firstChild).toMatchInlineSnapshot(` - * - * - * - * `); - * ``` - * - * @public - */ -export function render( - ui: ComponentChild, - options?: RenderOptions, -): RenderResult; -/** - * Cleanup elements rendered to the page and Preact trees that were mounted with render. - * - * @public - */ -export function cleanup(): void; - -/** - * The result of {@link renderHook} - * - * @public - */ - -export interface RenderHookResult { - /** - * Triggers a re-render. The props will be passed to your renderHook callback. - */ - rerender: (props?: Props) => void; - /** - * This is a stable reference to the latest value returned by your renderHook - * callback - */ - result: { - /** - * The value returned by your renderHook callback - */ - current: Result; - }; - /** - * Unmounts the test component. This is useful for when you need to test - * any cleanup your useEffects have. - */ - unmount: () => void; -} - -/** - * The options for {@link renderHook} - * - * @public - */ -export interface RenderHookOptions { - /** - * The argument passed to the renderHook callback. Can be useful if you plan - * to use the rerender utility to change the values passed to your hook. - */ - initialProps?: Props; - /** - * Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating - * reusable custom render functions for common data providers. See setup for examples. - * - * @example - * - * ```ts - * import { renderHook } from '@lynx-js/react/testing-library' - * import { ThemeProvider } from 'my-ui-lib' - * import { TranslationProvider } from 'my-i18n-lib' - * import defaultStrings from 'i18n/en-x-default' - * - * const AllTheProviders = ({children}) => { - * return ( - * - * - * {children} - * - * - * ) - * } - * - * const customRenderHook = (ui, options) => - * renderHook(ui, { wrapper: AllTheProviders, ...options }) - * - * // re-export everything - * export * from '@lynx-js/react/testing-library' - * - * // override renderHook method - * export { customRender as renderHook } - * ``` - */ - wrapper?: ComponentType<{ children: LynxElement }>; -} - -/** - * Allows you to render a hook within a test React component without having to - * create that component yourself. - * - * @example - * - * ```ts - * import { renderHook } from '@lynx-js/react/testing-library' - * - * const Context = createContext('default'); - * function Wrapper({ children }) { - * return {children}; - * } - * const { result } = renderHook( - * () => { - * return useContext(Context); - * }, - * { - * wrapper: Wrapper, - * }, - * ); - * - * expect(result.current).toEqual('provided'); - * ``` - * - * @public - */ -export function renderHook( - render: (initialProps: Props) => Result, - options?: RenderHookOptions, -): RenderHookResult; - -/** - * Wait for the next event loop. - * - * It will be useful when you want to wait for the next event loop to finish. - * - * @public - */ -export function waitSchedule(): Promise; diff --git a/packages/testing-library/test-environment/package.json b/packages/testing-library/test-environment/package.json index 994b001a51..4461cb77ee 100644 --- a/packages/testing-library/test-environment/package.json +++ b/packages/testing-library/test-environment/package.json @@ -1,6 +1,22 @@ { "name": "@lynx-js/test-environment", "version": "0.0.0", + "description": "A subset of a Lynx environment to be useful for testing", + "keywords": [ + "Lynx", + "ReactLynx", + "testing" + ], + "repository": { + "type": "git", + "url": "https://github.com/lynx-family/lynx-stack.git", + "directory": "packages/testing-library/test-environment" + }, + "license": "Apache-2.0", + "author": { + "name": "Yiming Li", + "email": "yimingli.cs@gmail.com" + }, "exports": { ".": { "default": "./dist/index.mjs", From 957c7f86d5fafbe91e34464327fe305925b669cc Mon Sep 17 00:00:00 2001 From: Qingyu Wang <40660121+colinaaa@users.noreply.github.com> Date: Thu, 24 Apr 2025 10:47:40 +0800 Subject: [PATCH 2/4] ci: run tsc on test-publish --- .github/workflows/test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index af0e52d865..40444334cc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -148,11 +148,15 @@ jobs: npx --registry http://localhost:4873 create-rspeedy-canary@latest --template react --dir create-rspeedy-regression cd create-rspeedy-regression pnpm install --registry=http://localhost:4873 + pnpm tsc --noEmit pnpm run build + pnpm tsc --noEmit npx --registry http://localhost:4873 create-rspeedy-canary@latest --template react-vitest-rltl --dir create-rspeedy-regression-vitest-rltl cd create-rspeedy-regression-vitest-rltl pnpm install --registry=http://localhost:4873 + pnpm tsc --noEmit pnpm run build + pnpm tsc --noEmit pnpm run test test-tools: needs: build From 725cb4ac6c23ba63ab3c388ff170e4d99a1c37ee Mon Sep 17 00:00:00 2001 From: Yiming Li Date: Thu, 24 Apr 2025 12:28:35 +0800 Subject: [PATCH 3/4] fix(testing-library): elementTree type --- .../etc/react-lynx-testing-library.api.md | 29 ++++++++++++++++++- .../react/testing-library/types/entry.d.ts | 1 + .../react/testing-library/types/index.d.ts | 9 +----- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/packages/react/testing-library/etc/react-lynx-testing-library.api.md b/packages/react/testing-library/etc/react-lynx-testing-library.api.md index 2d8b105d9a..c3d584a22b 100644 --- a/packages/react/testing-library/etc/react-lynx-testing-library.api.md +++ b/packages/react/testing-library/etc/react-lynx-testing-library.api.md @@ -7,6 +7,7 @@ import { ARIARole } from 'aria-query'; import { ComponentChild } from 'preact'; import { ComponentType } from 'preact'; +import { JSDOM } from 'jsdom'; import { OptionsReceived } from 'pretty-format'; import * as prettyFormat from 'pretty-format'; @@ -354,6 +355,11 @@ export interface DefaultNormalizerOptions { trim?: boolean } +// Warning: (ae-forgotten-export) The symbol "initElementTree" needs to be exported by the entry point entry.d.ts +// +// @public +export type ElementTree = ReturnType; + // Warning: (ae-missing-release-tag) "EventType" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -901,6 +907,27 @@ export interface LogRolesOptions { hidden?: boolean } +// @public +export class LynxEnv { + constructor(); + // Warning: (ae-forgotten-export) The symbol "LynxGlobalThis" needs to be exported by the entry point entry.d.ts + backgroundThread: LynxGlobalThis; + // (undocumented) + clearGlobal(): void; + // (undocumented) + injectGlobals(): void; + // (undocumented) + jsdom: JSDOM; + // Warning: (ae-forgotten-export) The symbol "ElementTreeGlobals" needs to be exported by the entry point entry.d.ts + mainThread: LynxGlobalThis & ElementTreeGlobals; + // (undocumented) + resetLynxEnv(): void; + // (undocumented) + switchToBackgroundThread(): void; + // (undocumented) + switchToMainThread(): void; +} + // Warning: (ae-missing-release-tag) "Match" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -1438,6 +1465,6 @@ export type WithSuggest = {suggest?: boolean} // Warnings were encountered during analysis: // -// types/entry.d.ts:214:29 - (ae-forgotten-export) The symbol "LynxElement" needs to be exported by the entry point entry.d.ts +// types/entry.d.ts:215:29 - (ae-forgotten-export) The symbol "LynxElement" needs to be exported by the entry point entry.d.ts ``` diff --git a/packages/react/testing-library/types/entry.d.ts b/packages/react/testing-library/types/entry.d.ts index 83030587c6..c7560bf9b8 100644 --- a/packages/react/testing-library/types/entry.d.ts +++ b/packages/react/testing-library/types/entry.d.ts @@ -11,6 +11,7 @@ import { queries, Queries, BoundFunction } from '@testing-library/dom'; import { LynxElement, type ElementTree, type LynxEnv } from '@lynx-js/test-environment'; import { ComponentChild, ComponentType } from 'preact'; export * from '@testing-library/dom'; +export { ElementTree, LynxEnv }; /** * The options for {@link render}. diff --git a/packages/react/testing-library/types/index.d.ts b/packages/react/testing-library/types/index.d.ts index 50939385bc..6f21459aa8 100644 --- a/packages/react/testing-library/types/index.d.ts +++ b/packages/react/testing-library/types/index.d.ts @@ -1,17 +1,10 @@ // @ts-nocheck export * from '../dist/index.d.ts'; +import { ElementTree, LynxEnv } from '../dist/index.d.ts'; declare global { var lynxEnv: LynxEnv; var elementTree: ElementTree; - var __JS__: boolean; - var __LEPUS__: boolean; - var __BACKGROUND__: boolean; - var __MAIN_THREAD__: boolean; - - namespace lynxCoreInject { - var tt: any; - } function onInjectBackgroundThreadGlobals(globals: any): void; function onInjectMainThreadGlobals(globals: any): void; From 9055bada5d80622230b8cabf1428e502a53e1250 Mon Sep 17 00:00:00 2001 From: Yiming Li Date: Thu, 24 Apr 2025 13:09:27 +0800 Subject: [PATCH 4/4] fix(testing-library): use rslib to build types --- cspell.jsonc | 1 - packages/react/package.json | 3 - .../react/testing-library/api-extractor.json | 9 - .../etc/react-lynx-testing-library.api.md | 1417 +---------------- packages/react/testing-library/package.json | 5 +- .../react/testing-library/rslib.config.ts | 11 + packages/react/testing-library/src/entry.ts | 2 + pnpm-lock.yaml | 18 +- 8 files changed, 35 insertions(+), 1431 deletions(-) create mode 100644 packages/react/testing-library/src/entry.ts diff --git a/cspell.jsonc b/cspell.jsonc index c5e9efb517..45de5e0786 100644 --- a/cspell.jsonc +++ b/cspell.jsonc @@ -152,7 +152,6 @@ "packages/react/types/*.d.ts", "packages/tools/css-serializer/**", "packages/web-platform/**", - "packages/react/testing-library/etc/react-lynx-testing-library.api.md", // Output "dist", "lib", diff --git a/packages/react/package.json b/packages/react/package.json index dda6619f46..086b460b30 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -164,11 +164,8 @@ "preact": "npm:@hongzhiyuan/preact@10.24.0-319c684e" }, "devDependencies": { - "@lynx-js/test-environment": "workspace:*", "@lynx-js/types": "^3.2.1", "@microsoft/api-extractor": "catalog:", - "@testing-library/dom": "^10.4.0", - "@testing-library/jest-dom": "^6.6.3", "@types/react": "^18.3.20" }, "peerDependencies": { diff --git a/packages/react/testing-library/api-extractor.json b/packages/react/testing-library/api-extractor.json index ec1eb75bdc..c275eb4cf6 100644 --- a/packages/react/testing-library/api-extractor.json +++ b/packages/react/testing-library/api-extractor.json @@ -12,13 +12,4 @@ }, }, }, - "bundledPackages": [ - "@testing-library/dom", - "@lynx-js/test-environment", - ], - "dtsRollup": { - "enabled": true, - "untrimmedFilePath": "", - "publicTrimmedFilePath": "/dist/index.d.ts", - }, } diff --git a/packages/react/testing-library/etc/react-lynx-testing-library.api.md b/packages/react/testing-library/etc/react-lynx-testing-library.api.md index c3d584a22b..73d2b96c32 100644 --- a/packages/react/testing-library/etc/react-lynx-testing-library.api.md +++ b/packages/react/testing-library/etc/react-lynx-testing-library.api.md @@ -4,1319 +4,21 @@ ```ts -import { ARIARole } from 'aria-query'; +import { BoundFunction } from '@testing-library/dom'; import { ComponentChild } from 'preact'; import { ComponentType } from 'preact'; -import { JSDOM } from 'jsdom'; -import { OptionsReceived } from 'pretty-format'; -import * as prettyFormat from 'pretty-format'; - -// Warning: (ae-missing-release-tag) "AllByAttribute" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type AllByAttribute = ( -attribute: string, -container: HTMLElement, -id: Matcher, -options?: MatcherOptions, -) => HTMLElement[] - -// Warning: (ae-missing-release-tag) "AllByBoundAttribute" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type AllByBoundAttribute = ( -container: HTMLElement, -id: Matcher, -options?: MatcherOptions, -) => T[] - -// Warning: (ae-missing-release-tag) "AllByRole" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type AllByRole = ( -container: HTMLElement, -role: ByRoleMatcher, -options?: ByRoleOptions, -) => T[] - -// Warning: (ae-missing-release-tag) "AllByText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type AllByText = ( -container: HTMLElement, -id: Matcher, -options?: SelectorMatcherOptions, -) => T[] - -// Warning: (ae-missing-release-tag) "BoundFunction" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type BoundFunction = T extends ( -container: HTMLElement, -...args: infer P -) => infer R -? (...args: P) => R -: never - -// Warning: (ae-missing-release-tag) "BoundFunctions" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type BoundFunctions = Q extends typeof queries -? { - getByLabelText( - ...args: Parameters>> - ): ReturnType> - getAllByLabelText( - ...args: Parameters>> - ): ReturnType> - queryByLabelText( - ...args: Parameters>> - ): ReturnType> - queryAllByLabelText( - ...args: Parameters>> - ): ReturnType> - findByLabelText( - ...args: Parameters>> - ): ReturnType> - findAllByLabelText( - ...args: Parameters>> - ): ReturnType> - getByPlaceholderText( - ...args: Parameters>> - ): ReturnType> - getAllByPlaceholderText( - ...args: Parameters>> - ): ReturnType> - queryByPlaceholderText( - ...args: Parameters>> - ): ReturnType> - queryAllByPlaceholderText( - ...args: Parameters>> - ): ReturnType> - findByPlaceholderText( - ...args: Parameters>> - ): ReturnType> - findAllByPlaceholderText( - ...args: Parameters>> - ): ReturnType> - getByText( - ...args: Parameters>> - ): ReturnType> - getAllByText( - ...args: Parameters>> - ): ReturnType> - queryByText( - ...args: Parameters>> - ): ReturnType> - queryAllByText( - ...args: Parameters>> - ): ReturnType> - findByText( - ...args: Parameters>> - ): ReturnType> - findAllByText( - ...args: Parameters>> - ): ReturnType> - getByAltText( - ...args: Parameters>> - ): ReturnType> - getAllByAltText( - ...args: Parameters>> - ): ReturnType> - queryByAltText( - ...args: Parameters>> - ): ReturnType> - queryAllByAltText( - ...args: Parameters>> - ): ReturnType> - findByAltText( - ...args: Parameters>> - ): ReturnType> - findAllByAltText( - ...args: Parameters>> - ): ReturnType> - getByTitle( - ...args: Parameters>> - ): ReturnType> - getAllByTitle( - ...args: Parameters>> - ): ReturnType> - queryByTitle( - ...args: Parameters>> - ): ReturnType> - queryAllByTitle( - ...args: Parameters>> - ): ReturnType> - findByTitle( - ...args: Parameters>> - ): ReturnType> - findAllByTitle( - ...args: Parameters>> - ): ReturnType> - getByDisplayValue( - ...args: Parameters>> - ): ReturnType> - getAllByDisplayValue( - ...args: Parameters>> - ): ReturnType> - queryByDisplayValue( - ...args: Parameters>> - ): ReturnType> - queryAllByDisplayValue( - ...args: Parameters>> - ): ReturnType> - findByDisplayValue( - ...args: Parameters>> - ): ReturnType> - findAllByDisplayValue( - ...args: Parameters>> - ): ReturnType> - getByRole( - ...args: Parameters>> - ): ReturnType> - getAllByRole( - ...args: Parameters>> - ): ReturnType> - queryByRole( - ...args: Parameters>> - ): ReturnType> - queryAllByRole( - ...args: Parameters>> - ): ReturnType> - findByRole( - ...args: Parameters>> - ): ReturnType> - findAllByRole( - ...args: Parameters>> - ): ReturnType> - getByTestId( - ...args: Parameters>> - ): ReturnType> - getAllByTestId( - ...args: Parameters>> - ): ReturnType> - queryByTestId( - ...args: Parameters>> - ): ReturnType> - queryAllByTestId( - ...args: Parameters>> - ): ReturnType> - findByTestId( - ...args: Parameters>> - ): ReturnType> - findAllByTestId( - ...args: Parameters>> - ): ReturnType> -} & { - [P in keyof Q]: BoundFunction -} -: { - [P in keyof Q]: BoundFunction -} - -// Warning: (ae-missing-release-tag) "buildQueries" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function buildQueries( -queryAllBy: GetAllBy, -getMultipleError: GetErrorFunction, -getMissingError: GetErrorFunction, -): BuiltQueryMethods - -// Warning: (ae-missing-release-tag) "BuiltQueryMethods" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type BuiltQueryMethods = [ -QueryBy, -GetAllBy, -GetBy, -FindAllBy, -FindBy, -] - -// Warning: (ae-missing-release-tag) "ByRoleMatcher" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type ByRoleMatcher = ARIARole | (string & {}) - -// Warning: (ae-missing-release-tag) "ByRoleOptions" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface ByRoleOptions { - busy?: boolean - checked?: boolean - current?: boolean | string - description?: - | RegExp - | string - | ((accessibleDescription: string, element: Element) => boolean) - expanded?: boolean - hidden?: boolean - level?: number - name?: - | RegExp - | string - | ((accessibleName: string, element: Element) => boolean) - pressed?: boolean - // Warning: (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag - // Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@" - queryFallbacks?: boolean - selected?: boolean - suggest?: boolean - // (undocumented) - value?: { - now?: number - min?: number - max?: number - text?: Matcher - } -} +import { ElementTree } from '@lynx-js/test-environment'; +import { LynxElement } from '@lynx-js/test-environment'; +import { LynxEnv } from '@lynx-js/test-environment'; +import { Queries } from '@testing-library/dom'; +import { queries } from '@testing-library/dom'; // @public export function cleanup(): void; -// Warning: (ae-missing-release-tag) "computeHeadingLevel" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function computeHeadingLevel(element: Element): number | undefined - -// Warning: (ae-missing-release-tag) "Config" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface Config { - // (undocumented) - asyncUtilTimeout: number - // (undocumented) - asyncWrapper(cb: (...args: any[]) => any): Promise - // (undocumented) - computedStyleSupportsPseudoElements: boolean - // (undocumented) - defaultHidden: boolean - defaultIgnore: string - // (undocumented) - eventWrapper(cb: (...args: any[]) => any): void - // (undocumented) - getElementError: (message: string | null, container: Element) => Error - // (undocumented) - showOriginalStackTrace: boolean - // (undocumented) - testIdAttribute: string - // (undocumented) - throwSuggestions: boolean - // Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen - unstable_advanceTimersWrapper(cb: (...args: unknown[]) => unknown): unknown -} - -// Warning: (ae-missing-release-tag) "ConfigFn" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface ConfigFn { - // (undocumented) - (existingConfig: Config): Partial -} - -// Warning: (ae-missing-release-tag) "configure" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function configure(configDelta: ConfigFn | Partial): void - -// Warning: (ae-missing-release-tag) "createEvent" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export const createEvent: CreateObject & CreateFunction; - -// Warning: (ae-missing-release-tag) "CreateFunction" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type CreateFunction = ( -eventName: string, -node: Document | Element | Window | Node, -init?: {}, -options?: {EventType?: string; defaultInit?: {}}, -) => Event - -// Warning: (ae-missing-release-tag) "CreateObject" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type CreateObject = { - [K in EventType]: ( - element: Document | Element | Window | Node, - options?: {}, - ) => Event -} - -// Warning: (ae-missing-release-tag) "DefaultNormalizerOptions" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface DefaultNormalizerOptions { - // (undocumented) - collapseWhitespace?: boolean - // (undocumented) - trim?: boolean -} - -// Warning: (ae-forgotten-export) The symbol "initElementTree" needs to be exported by the entry point entry.d.ts -// -// @public -export type ElementTree = ReturnType; - -// Warning: (ae-missing-release-tag) "EventType" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type EventType = -| 'copy' -| 'cut' -| 'paste' -| 'compositionEnd' -| 'compositionStart' -| 'compositionUpdate' -| 'keyDown' -| 'keyPress' -| 'keyUp' -| 'focus' -| 'blur' -| 'focusIn' -| 'focusOut' -| 'change' -| 'input' -| 'invalid' -| 'submit' -| 'reset' -| 'click' -| 'contextMenu' -| 'dblClick' -| 'drag' -| 'dragEnd' -| 'dragEnter' -| 'dragExit' -| 'dragLeave' -| 'dragOver' -| 'dragStart' -| 'drop' -| 'mouseDown' -| 'mouseEnter' -| 'mouseLeave' -| 'mouseMove' -| 'mouseOut' -| 'mouseOver' -| 'mouseUp' -| 'popState' -| 'select' -| 'touchCancel' -| 'touchEnd' -| 'touchMove' -| 'touchStart' -| 'resize' -| 'scroll' -| 'wheel' -| 'abort' -| 'canPlay' -| 'canPlayThrough' -| 'durationChange' -| 'emptied' -| 'encrypted' -| 'ended' -| 'loadedData' -| 'loadedMetadata' -| 'loadStart' -| 'pause' -| 'play' -| 'playing' -| 'progress' -| 'rateChange' -| 'seeked' -| 'seeking' -| 'stalled' -| 'suspend' -| 'timeUpdate' -| 'volumeChange' -| 'waiting' -| 'load' -| 'error' -| 'animationStart' -| 'animationEnd' -| 'animationIteration' -| 'transitionCancel' -| 'transitionEnd' -| 'transitionRun' -| 'transitionStart' -| 'doubleClick' -| 'pointerOver' -| 'pointerEnter' -| 'pointerDown' -| 'pointerMove' -| 'pointerUp' -| 'pointerCancel' -| 'pointerOut' -| 'pointerLeave' -| 'gotPointerCapture' -| 'lostPointerCapture' -| 'offline' -| 'online' -| 'pageHide' -| 'pageShow' - -// Warning: (ae-missing-release-tag) "FindAllBy" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type FindAllBy = QueryMethod< -[Arguments[0], Arguments[1]?, waitForOptions?], -Promise -> - -// Warning: (ae-missing-release-tag) "findAllByAltText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function findAllByAltText( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "FindAllByBoundAttribute" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type FindAllByBoundAttribute = ( -container: HTMLElement, -id: Matcher, -options?: MatcherOptions, -waitForElementOptions?: waitForOptions, -) => Promise - -// Warning: (ae-missing-release-tag) "findAllByDisplayValue" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function findAllByDisplayValue( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "findAllByLabelText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function findAllByLabelText( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "findAllByPlaceholderText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function findAllByPlaceholderText( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "FindAllByRole" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type FindAllByRole = ( -container: HTMLElement, -role: ByRoleMatcher, -options?: ByRoleOptions, -waitForElementOptions?: waitForOptions, -) => Promise - -// Warning: (ae-missing-release-tag) "findAllByRole" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function findAllByRole( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "findAllByTestId" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function findAllByTestId( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "FindAllByText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type FindAllByText = ( -container: HTMLElement, -id: Matcher, -options?: SelectorMatcherOptions, -waitForElementOptions?: waitForOptions, -) => Promise - -// Warning: (ae-missing-release-tag) "findAllByText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function findAllByText( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "findAllByTitle" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function findAllByTitle( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "FindBy" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type FindBy = QueryMethod< -[Arguments[0], Arguments[1]?, waitForOptions?], -Promise -> - -// Warning: (ae-missing-release-tag) "findByAltText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function findByAltText( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "FindByBoundAttribute" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type FindByBoundAttribute = ( -container: HTMLElement, -id: Matcher, -options?: MatcherOptions, -waitForElementOptions?: waitForOptions, -) => Promise - -// Warning: (ae-missing-release-tag) "findByDisplayValue" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function findByDisplayValue( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "findByLabelText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function findByLabelText( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "findByPlaceholderText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function findByPlaceholderText( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "FindByRole" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type FindByRole = ( -container: HTMLElement, -role: ByRoleMatcher, -options?: ByRoleOptions, -waitForElementOptions?: waitForOptions, -) => Promise - -// Warning: (ae-missing-release-tag) "findByRole" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function findByRole( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "findByTestId" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function findByTestId( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "FindByText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type FindByText = ( -container: HTMLElement, -id: Matcher, -options?: SelectorMatcherOptions, -waitForElementOptions?: waitForOptions, -) => Promise - -// Warning: (ae-missing-release-tag) "findByText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function findByText( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "findByTitle" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function findByTitle( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "fireEvent" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export const fireEvent: FireFunction & FireObject; - -// Warning: (ae-missing-release-tag) "FireFunction" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type FireFunction = ( -element: Document | Element | Window | Node, -event: Event, -) => boolean - -// Warning: (ae-missing-release-tag) "FireObject" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type FireObject = { - [K in EventType]: ( - element: Document | Element | Window | Node, - options?: {}, - ) => boolean -} - -// Warning: (ae-missing-release-tag) "GetAllBy" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type GetAllBy = QueryMethod< -Arguments, -HTMLElement[] -> - -// Warning: (ae-missing-release-tag) "getAllByAltText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function getAllByAltText( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "getAllByDisplayValue" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function getAllByDisplayValue( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "getAllByLabelText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function getAllByLabelText( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "getAllByPlaceholderText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function getAllByPlaceholderText( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "getAllByRole" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function getAllByRole( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "getAllByTestId" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function getAllByTestId( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "getAllByText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function getAllByText( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "getAllByTitle" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function getAllByTitle( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "GetBy" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type GetBy = QueryMethod - -// Warning: (ae-missing-release-tag) "getByAltText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function getByAltText( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "GetByBoundAttribute" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type GetByBoundAttribute = ( -container: HTMLElement, -id: Matcher, -options?: MatcherOptions, -) => T - -// Warning: (ae-missing-release-tag) "getByDisplayValue" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function getByDisplayValue( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "getByLabelText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function getByLabelText( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "getByPlaceholderText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function getByPlaceholderText( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "GetByRole" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type GetByRole = ( -container: HTMLElement, -role: ByRoleMatcher, -options?: ByRoleOptions, -) => T - -// Warning: (ae-missing-release-tag) "getByRole" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function getByRole( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "getByTestId" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function getByTestId( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "GetByText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type GetByText = ( -container: HTMLElement, -id: Matcher, -options?: SelectorMatcherOptions, -) => T - -// Warning: (ae-missing-release-tag) "getByText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function getByText( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "getByTitle" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function getByTitle( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "getConfig" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function getConfig(): Config +export { ElementTree } -// Warning: (ae-missing-release-tag) "getDefaultNormalizer" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function getDefaultNormalizer( -options?: DefaultNormalizerOptions, -): NormalizerFn - -// Warning: (ae-missing-release-tag) "getElementError" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function getElementError( -message: string | null, -container: HTMLElement, -): Error - -// Warning: (ae-missing-release-tag) "GetErrorFunction" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type GetErrorFunction = ( -c: Element | null, -...args: Arguments -) => string - -// Warning: (ae-missing-release-tag) "getNodeText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function getNodeText(node: HTMLElement): string - -// Warning: (ae-missing-release-tag) "getQueriesForElement" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function getQueriesForElement< -QueriesToBind extends Queries = typeof queries, -// Extra type parameter required for reassignment. -T extends QueriesToBind = QueriesToBind, ->(element: HTMLElement, queriesToBind?: T): BoundFunctions - -// Warning: (ae-missing-release-tag) "getRoles" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function getRoles(container: HTMLElement): { - [index: string]: HTMLElement[] -} - -// Warning: (ae-missing-release-tag) "getSuggestedQuery" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function getSuggestedQuery( -element: HTMLElement, -variant?: Variant, -method?: Method, -): Suggestion | undefined - -// Warning: (ae-missing-release-tag) "isInaccessible" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public -export function isInaccessible(element: Element): boolean - -// Warning: (ae-missing-release-tag) "logDOM" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function logDOM( -dom?: Element | HTMLDocument, -maxLength?: number, -options?: PrettyDOMOptions, -): void - -// Warning: (ae-missing-release-tag) "logRoles" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function logRoles( -container: HTMLElement, -options?: LogRolesOptions, -): string - -// Warning: (ae-missing-release-tag) "LogRolesOptions" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface LogRolesOptions { - // (undocumented) - hidden?: boolean -} - -// @public -export class LynxEnv { - constructor(); - // Warning: (ae-forgotten-export) The symbol "LynxGlobalThis" needs to be exported by the entry point entry.d.ts - backgroundThread: LynxGlobalThis; - // (undocumented) - clearGlobal(): void; - // (undocumented) - injectGlobals(): void; - // (undocumented) - jsdom: JSDOM; - // Warning: (ae-forgotten-export) The symbol "ElementTreeGlobals" needs to be exported by the entry point entry.d.ts - mainThread: LynxGlobalThis & ElementTreeGlobals; - // (undocumented) - resetLynxEnv(): void; - // (undocumented) - switchToBackgroundThread(): void; - // (undocumented) - switchToMainThread(): void; -} - -// Warning: (ae-missing-release-tag) "Match" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type Match = ( -textToMatch: string, -node: HTMLElement | null, -matcher: Matcher, -options?: MatcherOptions, -) => boolean - -// Warning: (ae-missing-release-tag) "Matcher" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type Matcher = MatcherFunction | RegExp | number | string - -// Warning: (ae-missing-release-tag) "MatcherFunction" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type MatcherFunction = ( -content: string, -element: Element | null, -) => boolean - -// Warning: (ae-missing-release-tag) "MatcherOptions" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface MatcherOptions { - collapseWhitespace?: boolean - // (undocumented) - exact?: boolean - // (undocumented) - normalizer?: NormalizerFn - suggest?: boolean - trim?: boolean -} - -// Warning: (ae-missing-release-tag) "Method" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type Method = -| 'AltText' -| 'alttext' -| 'DisplayValue' -| 'displayvalue' -| 'LabelText' -| 'labeltext' -| 'PlaceholderText' -| 'placeholdertext' -| 'Role' -| 'role' -| 'TestId' -| 'testid' -| 'Text' -| 'text' -| 'Title' -| 'title' - -// Warning: (ae-missing-release-tag) "NormalizerFn" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type NormalizerFn = (text: string) => string - -// Warning: (ae-missing-release-tag) "NormalizerOptions" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface NormalizerOptions extends DefaultNormalizerOptions { - // (undocumented) - normalizer?: NormalizerFn -} - -// Warning: (ae-missing-release-tag) "prettyDOM" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function prettyDOM( -dom?: Element | HTMLDocument, -maxLength?: number, -options?: PrettyDOMOptions, -): string | false - -// Warning: (ae-missing-release-tag) "PrettyDOMOptions" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface PrettyDOMOptions extends prettyFormat.OptionsReceived { - filterNode?: (node: Node) => boolean -} - -export { prettyFormat } - -// Warning: (ae-missing-release-tag) "Queries" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface Queries { - // (undocumented) - [T: string]: Query -} - -declare namespace queries { - export { - getByLabelText, - getAllByLabelText, - queryByLabelText, - queryAllByLabelText, - findByLabelText, - findAllByLabelText, - getByPlaceholderText, - getAllByPlaceholderText, - queryByPlaceholderText, - queryAllByPlaceholderText, - findByPlaceholderText, - findAllByPlaceholderText, - getByText, - getAllByText, - queryByText, - queryAllByText, - findByText, - findAllByText, - getByAltText, - getAllByAltText, - queryByAltText, - queryAllByAltText, - findByAltText, - findAllByAltText, - getByTitle, - getAllByTitle, - queryByTitle, - queryAllByTitle, - findByTitle, - findAllByTitle, - getByDisplayValue, - getAllByDisplayValue, - queryByDisplayValue, - queryAllByDisplayValue, - findByDisplayValue, - findAllByDisplayValue, - getByRole, - getAllByRole, - queryByRole, - queryAllByRole, - findByRole, - findAllByRole, - getByTestId, - getAllByTestId, - queryByTestId, - queryAllByTestId, - findByTestId, - findAllByTestId, - QueryByBoundAttribute, - AllByBoundAttribute, - FindAllByBoundAttribute, - GetByBoundAttribute, - FindByBoundAttribute, - QueryByText, - AllByText, - FindAllByText, - GetByText, - FindByText, - ByRoleOptions, - AllByRole, - GetByRole, - QueryByRole, - FindByRole, - FindAllByRole - } -} -export { queries } - -// Warning: (ae-missing-release-tag) "Query" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type Query = ( -container: HTMLElement, -...args: any[] -) => -| Error -| HTMLElement -| HTMLElement[] -| Promise -| Promise -| null - -// Warning: (ae-missing-release-tag) "queryAllByAltText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function queryAllByAltText( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "queryAllByAttribute" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export const queryAllByAttribute: AllByAttribute; - -// Warning: (ae-missing-release-tag) "queryAllByDisplayValue" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function queryAllByDisplayValue( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "queryAllByLabelText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function queryAllByLabelText( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "queryAllByPlaceholderText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function queryAllByPlaceholderText( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "queryAllByRole" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function queryAllByRole( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "queryAllByTestId" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function queryAllByTestId( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "queryAllByText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function queryAllByText( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "queryAllByTitle" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function queryAllByTitle( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "QueryArgs" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type QueryArgs = [string, QueryOptions?] - -// Warning: (ae-missing-release-tag) "QueryBy" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type QueryBy = QueryMethod< -Arguments, -HTMLElement | null -> - -// Warning: (ae-missing-release-tag) "queryByAltText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function queryByAltText( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "QueryByAttribute" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type QueryByAttribute = ( -attribute: string, -container: HTMLElement, -id: Matcher, -options?: MatcherOptions, -) => HTMLElement | null - -// Warning: (ae-missing-release-tag) "queryByAttribute" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export const queryByAttribute: QueryByAttribute; - -// Warning: (ae-missing-release-tag) "QueryByBoundAttribute" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type QueryByBoundAttribute = ( -container: HTMLElement, -id: Matcher, -options?: MatcherOptions, -) => T | null - -// Warning: (ae-missing-release-tag) "queryByDisplayValue" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function queryByDisplayValue( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "queryByLabelText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function queryByLabelText( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "queryByPlaceholderText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function queryByPlaceholderText( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "QueryByRole" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type QueryByRole = ( -container: HTMLElement, -role: ByRoleMatcher, -options?: ByRoleOptions, -) => T | null - -// Warning: (ae-missing-release-tag) "queryByRole" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function queryByRole( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "queryByTestId" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function queryByTestId( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "QueryByText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type QueryByText = ( -container: HTMLElement, -id: Matcher, -options?: SelectorMatcherOptions, -) => T | null - -// Warning: (ae-missing-release-tag) "queryByText" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function queryByText( -...args: Parameters> -): ReturnType> - -// Warning: (ae-missing-release-tag) "queryByTitle" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function queryByTitle( -...args: Parameters> -): ReturnType> - -declare namespace queryHelpers { - export { - getElementError, - buildQueries, - WithSuggest, - GetErrorFunction, - SelectorMatcherOptions, - QueryByAttribute, - AllByAttribute, - queryByAttribute, - queryAllByAttribute, - QueryMethod, - QueryBy, - GetAllBy, - FindAllBy, - GetBy, - FindBy, - BuiltQueryMethods - } -} -export { queryHelpers } - -// Warning: (ae-missing-release-tag) "QueryMethod" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public -export type QueryMethod = ( -container: HTMLElement, -...args: Arguments -) => Return - -// Warning: (ae-missing-release-tag) "QueryOptions" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface QueryOptions { - // (undocumented) - [key: string]: RegExp | boolean -} +export { LynxEnv } // @public export function render( @@ -1360,111 +62,10 @@ export type RenderResult = { unmount: () => boolean; } & { [P in keyof Q]: BoundFunction }; -// Warning: (ae-missing-release-tag) "Screen" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -type Screen_2 = BoundFunctions & { - debug: ( - element?: Array | Element | HTMLDocument, - maxLength?: number, - options?: OptionsReceived, - ) => void - logTestingPlaygroundURL: (element?: Element | HTMLDocument) => string -} -export { Screen_2 as Screen } - -// Warning: (ae-missing-release-tag) "screen" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -const screen_2: Screen_2; -export { screen_2 as screen } - -// Warning: (ae-missing-release-tag) "SelectorMatcherOptions" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface SelectorMatcherOptions extends MatcherOptions { - // (undocumented) - ignore?: boolean | string - // (undocumented) - selector?: string -} - -// Warning: (ae-missing-release-tag) "Suggestion" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface Suggestion { - // (undocumented) - queryArgs: QueryArgs - // (undocumented) - queryMethod: string - // (undocumented) - queryName: string - // (undocumented) - toString(): string - // (undocumented) - variant: string - // (undocumented) - warning?: string -} - -// Warning: (ae-missing-release-tag) "Variant" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type Variant = -| 'find' -| 'findAll' -| 'get' -| 'getAll' -| 'query' -| 'queryAll' - -// Warning: (ae-missing-release-tag) "waitFor" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function waitFor( -callback: () => Promise | T, -options?: waitForOptions, -): Promise - -// Warning: (ae-missing-release-tag) "waitForElementToBeRemoved" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export function waitForElementToBeRemoved( -callback: T | (() => T), -options?: waitForOptions, -): Promise - -// Warning: (ae-missing-release-tag) "waitForOptions" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface waitForOptions { - // (undocumented) - container?: HTMLElement - // (undocumented) - interval?: number - // (undocumented) - mutationObserverOptions?: MutationObserverInit - // (undocumented) - onTimeout?: (error: Error) => Error - // (undocumented) - timeout?: number -} - // @public export function waitSchedule(): Promise; -// Warning: (ae-missing-release-tag) "within" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export const within: typeof getQueriesForElement; - -// Warning: (ae-missing-release-tag) "WithSuggest" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type WithSuggest = {suggest?: boolean} -// Warnings were encountered during analysis: -// -// types/entry.d.ts:215:29 - (ae-forgotten-export) The symbol "LynxElement" needs to be exported by the entry point entry.d.ts +export * from "@testing-library/dom"; ``` diff --git a/packages/react/testing-library/package.json b/packages/react/testing-library/package.json index 5d68b93c95..f6053c1f4e 100644 --- a/packages/react/testing-library/package.json +++ b/packages/react/testing-library/package.json @@ -11,6 +11,9 @@ "test:ui": "vitest --ui" }, "devDependencies": { - "@lynx-js/react": "workspace:*" + "@lynx-js/react": "workspace:*", + "@lynx-js/test-environment": "workspace:*", + "@testing-library/dom": "^10.4.0", + "@testing-library/jest-dom": "^6.6.3" } } diff --git a/packages/react/testing-library/rslib.config.ts b/packages/react/testing-library/rslib.config.ts index 67225dc333..07636e9466 100644 --- a/packages/react/testing-library/rslib.config.ts +++ b/packages/react/testing-library/rslib.config.ts @@ -41,6 +41,17 @@ export default defineConfig({ ], }, }, + { + format: 'esm', + dts: { + bundle: true, + }, + source: { + entry: { + 'index': './src/entry.ts', + }, + }, + }, ], tools: { rspack(config) { diff --git a/packages/react/testing-library/src/entry.ts b/packages/react/testing-library/src/entry.ts new file mode 100644 index 0000000000..b9677f884c --- /dev/null +++ b/packages/react/testing-library/src/entry.ts @@ -0,0 +1,2 @@ +// @ts-ignore +export type * from '../../../types/entry.d.ts'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7a3d131dc1..e520f888c5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -183,21 +183,12 @@ importers: specifier: npm:@hongzhiyuan/preact@10.24.0-319c684e version: '@hongzhiyuan/preact@10.24.0-319c684e' devDependencies: - '@lynx-js/test-environment': - specifier: workspace:* - version: link:../testing-library/test-environment '@lynx-js/types': specifier: ^3.2.1 version: 3.2.1 '@microsoft/api-extractor': specifier: 'catalog:' version: 7.52.3(@types/node@22.14.1) - '@testing-library/dom': - specifier: ^10.4.0 - version: 10.4.0 - '@testing-library/jest-dom': - specifier: ^6.6.3 - version: 6.6.3 '@types/react': specifier: ^18.3.20 version: 18.3.20 @@ -252,6 +243,15 @@ importers: '@lynx-js/react': specifier: workspace:* version: link:.. + '@lynx-js/test-environment': + specifier: workspace:* + version: link:../../testing-library/test-environment + '@testing-library/dom': + specifier: ^10.4.0 + version: 10.4.0 + '@testing-library/jest-dom': + specifier: ^6.6.3 + version: 6.6.3 packages/react/transform: devDependencies: