alepha
Version:
Easy-to-use modern TypeScript framework for building many kind of applications.
729 lines • 38.6 kB
TypeScript
import { Alepha } from "alepha";
import { ReactElement, ReactNode } from "react";
import "react-dom/test-utils";
import * as ReactDOMClient from "react-dom/client";
import { ARIARole } from "aria-query";
//#region ../../../../node_modules/@testing-library/dom/types/matches.d.ts
type MatcherFunction = (content: string, element: Element | null) => boolean;
type Matcher = MatcherFunction | RegExp | number | string;
// Get autocomplete for ARIARole union types, while still supporting another string
// Ref: https://github.com/microsoft/TypeScript/issues/29729#issuecomment-567871939
type ByRoleMatcher = ARIARole | (string & {});
type NormalizerFn = (text: string) => string;
interface MatcherOptions {
exact?: boolean;
/** Use normalizer with getDefaultNormalizer instead */
trim?: boolean;
/** Use normalizer with getDefaultNormalizer instead */
collapseWhitespace?: boolean;
normalizer?: NormalizerFn;
/** suppress suggestions for a specific query */
suggest?: boolean;
}
//#endregion
//#region ../../../../node_modules/@testing-library/dom/types/wait-for.d.ts
interface waitForOptions {
container?: HTMLElement;
timeout?: number;
interval?: number;
onTimeout?: (error: Error) => Error;
mutationObserverOptions?: MutationObserverInit;
}
//#endregion
//#region ../../../../node_modules/@testing-library/dom/types/query-helpers.d.ts
interface SelectorMatcherOptions extends MatcherOptions {
selector?: string;
ignore?: boolean | string;
}
declare namespace queries_d_exports {
export { AllByBoundAttribute, AllByRole, AllByText, ByRoleOptions, FindAllByBoundAttribute, FindAllByRole, FindAllByText, FindByBoundAttribute, FindByRole, FindByText, GetByBoundAttribute, GetByRole, GetByText, QueryByBoundAttribute, QueryByRole, QueryByText, findAllByAltText, findAllByDisplayValue, findAllByLabelText, findAllByPlaceholderText, findAllByRole, findAllByTestId, findAllByText, findAllByTitle, findByAltText, findByDisplayValue, findByLabelText, findByPlaceholderText, findByRole, findByTestId, findByText, findByTitle, getAllByAltText, getAllByDisplayValue, getAllByLabelText, getAllByPlaceholderText, getAllByRole, getAllByTestId, getAllByText, getAllByTitle, getByAltText, getByDisplayValue, getByLabelText, getByPlaceholderText, getByRole, getByTestId, getByText, getByTitle, queryAllByAltText, queryAllByDisplayValue, queryAllByLabelText, queryAllByPlaceholderText, queryAllByRole, queryAllByTestId, queryAllByText, queryAllByTitle, queryByAltText, queryByDisplayValue, queryByLabelText, queryByPlaceholderText, queryByRole, queryByTestId, queryByText, queryByTitle };
}
type QueryByBoundAttribute<T extends HTMLElement = HTMLElement> = (container: HTMLElement, id: Matcher, options?: MatcherOptions) => T | null;
type AllByBoundAttribute<T extends HTMLElement = HTMLElement> = (container: HTMLElement, id: Matcher, options?: MatcherOptions) => T[];
type FindAllByBoundAttribute<T extends HTMLElement = HTMLElement> = (container: HTMLElement, id: Matcher, options?: MatcherOptions, waitForElementOptions?: waitForOptions) => Promise<T[]>;
type GetByBoundAttribute<T extends HTMLElement = HTMLElement> = (container: HTMLElement, id: Matcher, options?: MatcherOptions) => T;
type FindByBoundAttribute<T extends HTMLElement = HTMLElement> = (container: HTMLElement, id: Matcher, options?: MatcherOptions, waitForElementOptions?: waitForOptions) => Promise<T>;
type QueryByText<T extends HTMLElement = HTMLElement> = (container: HTMLElement, id: Matcher, options?: SelectorMatcherOptions) => T | null;
type AllByText<T extends HTMLElement = HTMLElement> = (container: HTMLElement, id: Matcher, options?: SelectorMatcherOptions) => T[];
type FindAllByText<T extends HTMLElement = HTMLElement> = (container: HTMLElement, id: Matcher, options?: SelectorMatcherOptions, waitForElementOptions?: waitForOptions) => Promise<T[]>;
type GetByText<T extends HTMLElement = HTMLElement> = (container: HTMLElement, id: Matcher, options?: SelectorMatcherOptions) => T;
type FindByText<T extends HTMLElement = HTMLElement> = (container: HTMLElement, id: Matcher, options?: SelectorMatcherOptions, waitForElementOptions?: waitForOptions) => Promise<T>;
interface ByRoleOptions {
/** suppress suggestions for a specific query */
suggest?: boolean;
/**
* If true includes elements in the query set that are usually excluded from
* the accessibility tree. `role="none"` or `role="presentation"` are included
* in either case.
*/
hidden?: boolean;
/**
* If true only includes elements in the query set that are marked as
* selected in the accessibility tree, i.e., `aria-selected="true"`
*/
selected?: boolean;
/**
* If true only includes elements in the query set that are marked as
* busy in the accessibility tree, i.e., `aria-busy="true"`
*/
busy?: boolean;
/**
* If true only includes elements in the query set that are marked as
* checked in the accessibility tree, i.e., `aria-checked="true"`
*/
checked?: boolean;
/**
* If true only includes elements in the query set that are marked as
* pressed in the accessibility tree, i.e., `aria-pressed="true"`
*/
pressed?: boolean;
/**
* Filters elements by their `aria-current` state. `true` and `false` match `aria-current="true"` and `aria-current="false"` (as well as a missing `aria-current` attribute) respectively.
*/
current?: boolean | string;
/**
* If true only includes elements in the query set that are marked as
* expanded in the accessibility tree, i.e., `aria-expanded="true"`
*/
expanded?: boolean;
/**
* Includes elements with the `"heading"` role matching the indicated level,
* either by the semantic HTML heading elements `<h1>-<h6>` or matching
* the `aria-level` attribute.
*/
level?: number;
value?: {
now?: number;
min?: number;
max?: number;
text?: Matcher;
};
/**
* Includes every role used in the `role` attribute
* For example *ByRole('progressbar', {queryFallbacks: true})` will find <div role="meter progressbar">`.
*/
queryFallbacks?: boolean;
/**
* Only considers elements with the specified accessible name.
*/
name?: RegExp | string | ((accessibleName: string, element: Element) => boolean);
/**
* Only considers elements with the specified accessible description.
*/
description?: RegExp | string | ((accessibleDescription: string, element: Element) => boolean);
}
type AllByRole<T extends HTMLElement = HTMLElement> = (container: HTMLElement, role: ByRoleMatcher, options?: ByRoleOptions) => T[];
type GetByRole<T extends HTMLElement = HTMLElement> = (container: HTMLElement, role: ByRoleMatcher, options?: ByRoleOptions) => T;
type QueryByRole<T extends HTMLElement = HTMLElement> = (container: HTMLElement, role: ByRoleMatcher, options?: ByRoleOptions) => T | null;
type FindByRole<T extends HTMLElement = HTMLElement> = (container: HTMLElement, role: ByRoleMatcher, options?: ByRoleOptions, waitForElementOptions?: waitForOptions) => Promise<T>;
type FindAllByRole<T extends HTMLElement = HTMLElement> = (container: HTMLElement, role: ByRoleMatcher, options?: ByRoleOptions, waitForElementOptions?: waitForOptions) => Promise<T[]>;
declare function getByLabelText<T extends HTMLElement = HTMLElement>(...args: Parameters<GetByText<T>>): ReturnType<GetByText<T>>;
declare function getAllByLabelText<T extends HTMLElement = HTMLElement>(...args: Parameters<AllByText<T>>): ReturnType<AllByText<T>>;
declare function queryByLabelText<T extends HTMLElement = HTMLElement>(...args: Parameters<QueryByText<T>>): ReturnType<QueryByText<T>>;
declare function queryAllByLabelText<T extends HTMLElement = HTMLElement>(...args: Parameters<AllByText<T>>): ReturnType<AllByText<T>>;
declare function findByLabelText<T extends HTMLElement = HTMLElement>(...args: Parameters<FindByText<T>>): ReturnType<FindByText<T>>;
declare function findAllByLabelText<T extends HTMLElement = HTMLElement>(...args: Parameters<FindAllByText<T>>): ReturnType<FindAllByText<T>>;
declare function getByPlaceholderText<T extends HTMLElement = HTMLElement>(...args: Parameters<GetByBoundAttribute<T>>): ReturnType<GetByBoundAttribute<T>>;
declare function getAllByPlaceholderText<T extends HTMLElement = HTMLElement>(...args: Parameters<AllByBoundAttribute<T>>): ReturnType<AllByBoundAttribute<T>>;
declare function queryByPlaceholderText<T extends HTMLElement = HTMLElement>(...args: Parameters<QueryByBoundAttribute<T>>): ReturnType<QueryByBoundAttribute<T>>;
declare function queryAllByPlaceholderText<T extends HTMLElement = HTMLElement>(...args: Parameters<AllByBoundAttribute<T>>): ReturnType<AllByBoundAttribute<T>>;
declare function findByPlaceholderText<T extends HTMLElement = HTMLElement>(...args: Parameters<FindByBoundAttribute<T>>): ReturnType<FindByBoundAttribute<T>>;
declare function findAllByPlaceholderText<T extends HTMLElement = HTMLElement>(...args: Parameters<FindAllByBoundAttribute<T>>): ReturnType<FindAllByBoundAttribute<T>>;
declare function getByText<T extends HTMLElement = HTMLElement>(...args: Parameters<GetByText<T>>): ReturnType<GetByText<T>>;
declare function getAllByText<T extends HTMLElement = HTMLElement>(...args: Parameters<AllByText<T>>): ReturnType<AllByText<T>>;
declare function queryByText<T extends HTMLElement = HTMLElement>(...args: Parameters<QueryByText<T>>): ReturnType<QueryByText<T>>;
declare function queryAllByText<T extends HTMLElement = HTMLElement>(...args: Parameters<AllByText<T>>): ReturnType<AllByText<T>>;
declare function findByText<T extends HTMLElement = HTMLElement>(...args: Parameters<FindByText<T>>): ReturnType<FindByText<T>>;
declare function findAllByText<T extends HTMLElement = HTMLElement>(...args: Parameters<FindAllByText<T>>): ReturnType<FindAllByText<T>>;
declare function getByAltText<T extends HTMLElement = HTMLElement>(...args: Parameters<GetByBoundAttribute<T>>): ReturnType<GetByBoundAttribute<T>>;
declare function getAllByAltText<T extends HTMLElement = HTMLElement>(...args: Parameters<AllByBoundAttribute<T>>): ReturnType<AllByBoundAttribute<T>>;
declare function queryByAltText<T extends HTMLElement = HTMLElement>(...args: Parameters<QueryByBoundAttribute<T>>): ReturnType<QueryByBoundAttribute<T>>;
declare function queryAllByAltText<T extends HTMLElement = HTMLElement>(...args: Parameters<AllByBoundAttribute<T>>): ReturnType<AllByBoundAttribute<T>>;
declare function findByAltText<T extends HTMLElement = HTMLElement>(...args: Parameters<FindByBoundAttribute<T>>): ReturnType<FindByBoundAttribute<T>>;
declare function findAllByAltText<T extends HTMLElement = HTMLElement>(...args: Parameters<FindAllByBoundAttribute<T>>): ReturnType<FindAllByBoundAttribute<T>>;
declare function getByTitle<T extends HTMLElement = HTMLElement>(...args: Parameters<GetByBoundAttribute<T>>): ReturnType<GetByBoundAttribute<T>>;
declare function getAllByTitle<T extends HTMLElement = HTMLElement>(...args: Parameters<AllByBoundAttribute<T>>): ReturnType<AllByBoundAttribute<T>>;
declare function queryByTitle<T extends HTMLElement = HTMLElement>(...args: Parameters<QueryByBoundAttribute<T>>): ReturnType<QueryByBoundAttribute<T>>;
declare function queryAllByTitle<T extends HTMLElement = HTMLElement>(...args: Parameters<AllByBoundAttribute<T>>): ReturnType<AllByBoundAttribute<T>>;
declare function findByTitle<T extends HTMLElement = HTMLElement>(...args: Parameters<FindByBoundAttribute<T>>): ReturnType<FindByBoundAttribute<T>>;
declare function findAllByTitle<T extends HTMLElement = HTMLElement>(...args: Parameters<FindAllByBoundAttribute<T>>): ReturnType<FindAllByBoundAttribute<T>>;
declare function getByDisplayValue<T extends HTMLElement = HTMLElement>(...args: Parameters<GetByBoundAttribute<T>>): ReturnType<GetByBoundAttribute<T>>;
declare function getAllByDisplayValue<T extends HTMLElement = HTMLElement>(...args: Parameters<AllByBoundAttribute<T>>): ReturnType<AllByBoundAttribute<T>>;
declare function queryByDisplayValue<T extends HTMLElement = HTMLElement>(...args: Parameters<QueryByBoundAttribute<T>>): ReturnType<QueryByBoundAttribute<T>>;
declare function queryAllByDisplayValue<T extends HTMLElement = HTMLElement>(...args: Parameters<AllByBoundAttribute<T>>): ReturnType<AllByBoundAttribute<T>>;
declare function findByDisplayValue<T extends HTMLElement = HTMLElement>(...args: Parameters<FindByBoundAttribute<T>>): ReturnType<FindByBoundAttribute<T>>;
declare function findAllByDisplayValue<T extends HTMLElement = HTMLElement>(...args: Parameters<FindAllByBoundAttribute<T>>): ReturnType<FindAllByBoundAttribute<T>>;
declare function getByRole<T extends HTMLElement = HTMLElement>(...args: Parameters<GetByRole<T>>): ReturnType<GetByRole<T>>;
declare function getAllByRole<T extends HTMLElement = HTMLElement>(...args: Parameters<AllByRole<T>>): ReturnType<AllByRole<T>>;
declare function queryByRole<T extends HTMLElement = HTMLElement>(...args: Parameters<QueryByRole<T>>): ReturnType<QueryByRole<T>>;
declare function queryAllByRole<T extends HTMLElement = HTMLElement>(...args: Parameters<AllByRole<T>>): ReturnType<AllByRole<T>>;
declare function findByRole<T extends HTMLElement = HTMLElement>(...args: Parameters<FindByRole<T>>): ReturnType<FindByRole<T>>;
declare function findAllByRole<T extends HTMLElement = HTMLElement>(...args: Parameters<FindAllByRole<T>>): ReturnType<FindAllByRole<T>>;
declare function getByTestId<T extends HTMLElement = HTMLElement>(...args: Parameters<GetByBoundAttribute<T>>): ReturnType<GetByBoundAttribute<T>>;
declare function getAllByTestId<T extends HTMLElement = HTMLElement>(...args: Parameters<AllByBoundAttribute<T>>): ReturnType<AllByBoundAttribute<T>>;
declare function queryByTestId<T extends HTMLElement = HTMLElement>(...args: Parameters<QueryByBoundAttribute<T>>): ReturnType<QueryByBoundAttribute<T>>;
declare function queryAllByTestId<T extends HTMLElement = HTMLElement>(...args: Parameters<AllByBoundAttribute<T>>): ReturnType<AllByBoundAttribute<T>>;
declare function findByTestId<T extends HTMLElement = HTMLElement>(...args: Parameters<FindByBoundAttribute<T>>): ReturnType<FindByBoundAttribute<T>>;
declare function findAllByTestId<T extends HTMLElement = HTMLElement>(...args: Parameters<FindAllByBoundAttribute<T>>): ReturnType<FindAllByBoundAttribute<T>>;
//#endregion
//#region ../../../../node_modules/@testing-library/dom/types/get-queries-for-element.d.ts
type BoundFunction<T> = T extends ((container: HTMLElement, ...args: infer P) => infer R) ? (...args: P) => R : never;
type BoundFunctions<Q> = Q extends typeof queries_d_exports ? {
getByLabelText<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<GetByText<T>>>): ReturnType<GetByText<T>>;
getAllByLabelText<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<AllByText<T>>>): ReturnType<AllByText<T>>;
queryByLabelText<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<QueryByText<T>>>): ReturnType<QueryByText<T>>;
queryAllByLabelText<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<AllByText<T>>>): ReturnType<AllByText<T>>;
findByLabelText<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<FindByText<T>>>): ReturnType<FindByText<T>>;
findAllByLabelText<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<FindAllByText<T>>>): ReturnType<FindAllByText<T>>;
getByPlaceholderText<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<GetByBoundAttribute<T>>>): ReturnType<GetByBoundAttribute<T>>;
getAllByPlaceholderText<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<AllByBoundAttribute<T>>>): ReturnType<AllByBoundAttribute<T>>;
queryByPlaceholderText<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<QueryByBoundAttribute<T>>>): ReturnType<QueryByBoundAttribute<T>>;
queryAllByPlaceholderText<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<AllByBoundAttribute<T>>>): ReturnType<AllByBoundAttribute<T>>;
findByPlaceholderText<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<FindByBoundAttribute<T>>>): ReturnType<FindByBoundAttribute<T>>;
findAllByPlaceholderText<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<FindAllByBoundAttribute<T>>>): ReturnType<FindAllByBoundAttribute<T>>;
getByText<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<GetByText<T>>>): ReturnType<GetByText<T>>;
getAllByText<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<AllByText<T>>>): ReturnType<AllByText<T>>;
queryByText<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<QueryByText<T>>>): ReturnType<QueryByText<T>>;
queryAllByText<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<AllByText<T>>>): ReturnType<AllByText<T>>;
findByText<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<FindByText<T>>>): ReturnType<FindByText<T>>;
findAllByText<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<FindAllByText<T>>>): ReturnType<FindAllByText<T>>;
getByAltText<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<GetByBoundAttribute<T>>>): ReturnType<GetByBoundAttribute<T>>;
getAllByAltText<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<AllByBoundAttribute<T>>>): ReturnType<AllByBoundAttribute<T>>;
queryByAltText<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<QueryByBoundAttribute<T>>>): ReturnType<QueryByBoundAttribute<T>>;
queryAllByAltText<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<AllByBoundAttribute<T>>>): ReturnType<AllByBoundAttribute<T>>;
findByAltText<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<FindByBoundAttribute<T>>>): ReturnType<FindByBoundAttribute<T>>;
findAllByAltText<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<FindAllByBoundAttribute<T>>>): ReturnType<FindAllByBoundAttribute<T>>;
getByTitle<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<GetByBoundAttribute<T>>>): ReturnType<GetByBoundAttribute<T>>;
getAllByTitle<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<AllByBoundAttribute<T>>>): ReturnType<AllByBoundAttribute<T>>;
queryByTitle<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<QueryByBoundAttribute<T>>>): ReturnType<QueryByBoundAttribute<T>>;
queryAllByTitle<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<AllByBoundAttribute<T>>>): ReturnType<AllByBoundAttribute<T>>;
findByTitle<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<FindByBoundAttribute<T>>>): ReturnType<FindByBoundAttribute<T>>;
findAllByTitle<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<FindAllByBoundAttribute<T>>>): ReturnType<FindAllByBoundAttribute<T>>;
getByDisplayValue<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<GetByBoundAttribute<T>>>): ReturnType<GetByBoundAttribute<T>>;
getAllByDisplayValue<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<AllByBoundAttribute<T>>>): ReturnType<AllByBoundAttribute<T>>;
queryByDisplayValue<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<QueryByBoundAttribute<T>>>): ReturnType<QueryByBoundAttribute<T>>;
queryAllByDisplayValue<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<AllByBoundAttribute<T>>>): ReturnType<AllByBoundAttribute<T>>;
findByDisplayValue<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<FindByBoundAttribute<T>>>): ReturnType<FindByBoundAttribute<T>>;
findAllByDisplayValue<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<FindAllByBoundAttribute<T>>>): ReturnType<FindAllByBoundAttribute<T>>;
getByRole<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<GetByRole<T>>>): ReturnType<GetByRole<T>>;
getAllByRole<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<AllByRole<T>>>): ReturnType<AllByRole<T>>;
queryByRole<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<QueryByRole<T>>>): ReturnType<QueryByRole<T>>;
queryAllByRole<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<AllByRole<T>>>): ReturnType<AllByRole<T>>;
findByRole<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<FindByRole<T>>>): ReturnType<FindByRole<T>>;
findAllByRole<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<FindAllByRole<T>>>): ReturnType<FindAllByRole<T>>;
getByTestId<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<GetByBoundAttribute<T>>>): ReturnType<GetByBoundAttribute<T>>;
getAllByTestId<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<AllByBoundAttribute<T>>>): ReturnType<AllByBoundAttribute<T>>;
queryByTestId<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<QueryByBoundAttribute<T>>>): ReturnType<QueryByBoundAttribute<T>>;
queryAllByTestId<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<AllByBoundAttribute<T>>>): ReturnType<AllByBoundAttribute<T>>;
findByTestId<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<FindByBoundAttribute<T>>>): ReturnType<FindByBoundAttribute<T>>;
findAllByTestId<T extends HTMLElement = HTMLElement>(...args: Parameters<BoundFunction<FindAllByBoundAttribute<T>>>): ReturnType<FindAllByBoundAttribute<T>>;
} & { [P in keyof Q]: BoundFunction<Q[P]>; } : { [P in keyof Q]: BoundFunction<Q[P]>; };
type Query = (container: HTMLElement, ...args: any[]) => Error | HTMLElement | HTMLElement[] | Promise<HTMLElement[]> | Promise<HTMLElement> | null;
interface Queries {
[T: string]: Query;
}
//#endregion
//#region ../../../../node_modules/pretty-format/build/types.d.ts
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
declare type Colors = {
comment: {
close: string;
open: string;
};
content: {
close: string;
open: string;
};
prop: {
close: string;
open: string;
};
tag: {
close: string;
open: string;
};
value: {
close: string;
open: string;
};
};
declare type Indent = (arg0: string) => string;
declare type Refs = Array<unknown>;
declare type Print = (arg0: unknown) => string;
declare type ThemeReceived = {
comment?: string;
content?: string;
prop?: string;
tag?: string;
value?: string;
};
declare type CompareKeys = ((a: string, b: string) => number) | undefined;
interface PrettyFormatOptions {
callToJSON?: boolean;
compareKeys?: CompareKeys;
escapeRegex?: boolean;
escapeString?: boolean;
highlight?: boolean;
indent?: number;
maxDepth?: number;
min?: boolean;
plugins?: Plugins;
printBasicPrototype?: boolean;
printFunctionName?: boolean;
theme?: ThemeReceived;
}
declare type OptionsReceived = PrettyFormatOptions;
declare type Config = {
callToJSON: boolean;
compareKeys: CompareKeys;
colors: Colors;
escapeRegex: boolean;
escapeString: boolean;
indent: string;
maxDepth: number;
min: boolean;
plugins: Plugins;
printBasicPrototype: boolean;
printFunctionName: boolean;
spacingInner: string;
spacingOuter: string;
};
declare type Printer = (val: unknown, config: Config, indentation: string, depth: number, refs: Refs, hasCalledToJSON?: boolean) => string;
declare type Test = (arg0: any) => boolean;
declare type NewPlugin = {
serialize: (val: any, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
test: Test;
};
declare type PluginOptions = {
edgeSpacing: string;
min: boolean;
spacing: string;
};
declare type OldPlugin = {
print: (val: unknown, print: Print, indent: Indent, options: PluginOptions, colors: Colors) => string;
test: Test;
};
declare type Plugin = NewPlugin | OldPlugin;
declare type Plugins = Array<Plugin>;
//#endregion
//#region ../../../../node_modules/@testing-library/dom/types/screen.d.ts
type Screen<Q extends Queries = typeof queries_d_exports> = BoundFunctions<Q> & {
/**
* Convenience function for `pretty-dom` which also allows an array
* of elements
*/
debug: (element?: Array<Element | HTMLDocument> | Element | HTMLDocument, maxLength?: number, options?: OptionsReceived) => void;
/**
* Convenience function for `Testing Playground` which logs and returns the URL that
* can be opened in a browser
*/
logTestingPlaygroundURL: (element?: Element | HTMLDocument) => string;
};
//#endregion
//#region ../../../../node_modules/@testing-library/react/types/index.d.ts
type RenderResult<Q extends Queries = typeof queries_d_exports, Container extends RendererableContainer | HydrateableContainer = HTMLElement, BaseElement extends RendererableContainer | HydrateableContainer = Container> = {
container: Container;
baseElement: BaseElement;
debug: (baseElement?: RendererableContainer | HydrateableContainer | Array<RendererableContainer | HydrateableContainer> | undefined, maxLength?: number | undefined, options?: OptionsReceived | undefined) => void;
rerender: (ui: React.ReactNode) => void;
unmount: () => void;
asFragment: () => DocumentFragment;
} & { [P in keyof Q]: BoundFunction<Q[P]>; };
type RendererableContainer = ReactDOMClient.Container;
type HydrateableContainer = Parameters<typeof ReactDOMClient['hydrateRoot']>[0];
interface RenderOptions<Q extends Queries = typeof queries_d_exports, Container extends RendererableContainer | HydrateableContainer = HTMLElement, BaseElement extends RendererableContainer | HydrateableContainer = Container> {
/**
* By default, React Testing Library will create a div and append that div to the document.body. Your React component will be rendered in the created div. If you provide your own HTMLElement container via this option,
* it will not be appended to the document.body automatically.
*
* For example: If you are unit testing a `<tbody>` element, it cannot be a child of a div. In this case, you can
* specify a table as the render container.
*
* @see https://testing-library.com/docs/react-testing-library/api/#container
*/
container?: Container | undefined;
/**
* Defaults to the container if the container is specified. Otherwise `document.body` is used for the default. This is used as
* the base element for the queries as well as what is printed when you use `debug()`.
*
* @see https://testing-library.com/docs/react-testing-library/api/#baseelement
*/
baseElement?: BaseElement | undefined;
/**
* If `hydrate` is set to `true`, then it will render with `ReactDOM.hydrate`. This may be useful if you are using server-side
* rendering and use ReactDOM.hydrate to mount your components.
*
* @see https://testing-library.com/docs/react-testing-library/api/#hydrate)
*/
hydrate?: boolean | undefined;
/**
* Only works if used with React 18.
* Set to `true` if you want to force synchronous `ReactDOM.render`.
* Otherwise `render` will default to concurrent React if available.
*/
legacyRoot?: boolean | undefined;
/**
* Only supported in React 19.
* Callback called when React catches an error in an Error Boundary.
* Called with the error caught by the Error Boundary, and an `errorInfo` object containing the `componentStack`.
*
* @see {@link https://react.dev/reference/react-dom/client/createRoot#parameters createRoot#options}
*/
onCaughtError?: ReactDOMClient.RootOptions extends {
onCaughtError?: infer OnCaughtError;
} ? OnCaughtError : never;
/**
* Callback called when React automatically recovers from errors.
* Called with an error React throws, and an `errorInfo` object containing the `componentStack`.
* Some recoverable errors may include the original error cause as `error.cause`.
*
* @see {@link https://react.dev/reference/react-dom/client/createRoot#parameters createRoot#options}
*/
onRecoverableError?: ReactDOMClient.RootOptions['onRecoverableError'];
/**
* Not supported at the moment
*/
onUncaughtError?: never;
/**
* Queries to bind. Overrides the default set from DOM Testing Library unless merged.
*
* @see https://testing-library.com/docs/react-testing-library/api/#queries
*/
queries?: Q | undefined;
/**
* 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.
*
* @see https://testing-library.com/docs/react-testing-library/api/#wrapper
*/
wrapper?: React.JSXElementConstructor<{
children: React.ReactNode;
}> | undefined;
/**
* When enabled, <StrictMode> is rendered around the inner element.
* If defined, overrides the value of `reactStrictMode` set in `configure`.
*/
reactStrictMode?: boolean;
}
//#endregion
//#region ../../src/react/testing/form.d.ts
/**
* Options for fillForm helper.
*/
interface FillFormOptions {
/**
* Timeout for waiting for elements to appear.
* @default 1000
*/
timeout?: number;
}
/**
* Fill form fields by their values.
*
* This helper finds form inputs by their test IDs (based on form ID and field name)
* and sets their values using fireEvent.
*
* @param screen - The screen object from @testing-library/react
* @param formId - The form's ID (used to construct test IDs)
* @param values - Object with field names as keys and values to fill
* @param options - Fill options
*
* @example
* ```tsx
* import { fillForm } from "alepha/react/testing";
*
* // For a form with id="user-form" and fields: name, email, age
* await fillForm(screen, "user-form", {
* name: "Alice",
* email: "alice@example.com",
* age: 30,
* });
* ```
*
* @example
* ```tsx
* // For nested fields (e.g., address.city)
* await fillForm(screen, "user-form", {
* "address.city": "New York",
* "address.zip": "10001",
* });
* ```
*/
declare const fillForm: (screen: Screen, formId: string, values: Record<string, string | number | boolean>, options?: FillFormOptions) => Promise<void>;
/**
* Fill a single form field by its test ID.
*
* @param screen - The screen object from @testing-library/react
* @param testId - The element's test ID
* @param value - The value to set
*
* @example
* ```tsx
* import { fillField } from "alepha/react/testing";
*
* await fillField(screen, "user-form-email", "alice@example.com");
* ```
*/
declare const fillField: (screen: Screen, testId: string, value: string | number | boolean) => Promise<void>;
/**
* Options for submitForm helper.
*/
interface SubmitFormOptions {
/**
* Text of the submit button to click.
* @default "Submit"
*/
submitButtonText?: string;
/**
* Timeout for waiting for submission to complete.
* @default 1000
*/
timeout?: number;
/**
* Whether to wait for a form:submit:success event.
* @default false
*/
waitForSuccess?: boolean;
}
/**
* Submit a form by clicking the submit button.
*
* @param screen - The screen object from @testing-library/react
* @param options - Submit options
*
* @example
* ```tsx
* import { submitForm } from "alepha/react/testing";
*
* // Submit by clicking "Submit" button (default)
* await submitForm(screen);
*
* // Submit by clicking a custom button
* await submitForm(screen, { submitButtonText: "Save" });
* ```
*/
declare const submitForm: (screen: Screen, options?: SubmitFormOptions) => Promise<void>;
/**
* Reset a form by clicking the reset button.
*
* @param screen - The screen object from @testing-library/react
* @param resetButtonText - Text of the reset button
*
* @example
* ```tsx
* import { resetForm } from "alepha/react/testing";
*
* await resetForm(screen); // Clicks "Reset" button
* await resetForm(screen, "Clear"); // Clicks "Clear" button
* ```
*/
declare const resetForm: (screen: Screen, resetButtonText?: string) => Promise<void>;
/**
* Wait for a form submission to complete by listening for the form:submit:end event.
*
* @param alepha - The Alepha instance
* @param formId - The form's ID
* @param timeout - Maximum time to wait in ms
*
* @example
* ```tsx
* import { waitForFormSubmit } from "alepha/react/testing";
*
* fireEvent.click(submitButton);
* await waitForFormSubmit(alepha, "my-form");
* // Form submission is now complete
* ```
*/
declare const waitForFormSubmit: (alepha: {
events: {
once: (event: string, handler: (data: any) => void) => () => void;
};
}, formId: string, timeout?: number) => Promise<void>;
/**
* Toggle a switch or checkbox element.
*
* @param screen - The screen object from @testing-library/react
* @param role - The role to find the element by ("switch" or "checkbox")
* @param name - Optional accessible name to find a specific element
*
* @example
* ```tsx
* import { toggleSwitch } from "alepha/react/testing";
*
* // Toggle the first switch on the page
* await toggleSwitch(screen, "switch");
*
* // Toggle a specific switch by its label
* await toggleSwitch(screen, "switch", "Enable notifications");
* ```
*/
declare const toggleSwitch: (screen: Screen, role?: "switch" | "checkbox", name?: string) => Promise<void>;
//#endregion
//#region ../../src/react/testing/render.d.ts
/**
* Options for renderWithAlepha.
*/
interface RenderWithAlephaOptions extends Omit<RenderOptions, "wrapper"> {
/**
* Pre-configured Alepha instance to use.
* If not provided, a new instance with AlephaLogger will be created.
*/
alepha?: Alepha;
/**
* Whether to automatically start the Alepha instance.
* @default true
*/
autoStart?: boolean;
/**
* Wrapper component to wrap around the rendered element.
* Use this for UI framework providers (theme, etc.) or custom context providers.
*
* @example
* ```tsx
* import { ThemeProvider } from "my-ui-library";
* renderWithAlepha(<MyComponent />, { wrapper: ThemeProvider });
* ```
*/
wrapper?: React.ComponentType<{
children: ReactNode;
}>;
}
/**
* Result of renderWithAlepha, extending the standard render result.
*/
interface RenderWithAlephaResult extends RenderResult {
/**
* The Alepha instance used for rendering.
*/
alepha: Alepha;
}
/**
* Render a React element with Alepha context for testing.
*
* This is a convenience wrapper around `@testing-library/react`'s `render` function
* that automatically sets up the AlephaContext.Provider.
*
* @param element - The React element to render
* @param options - Render options
* @returns The render result with the Alepha instance
*
* @example
* ```tsx
* import { renderWithAlepha } from "alepha/react/testing";
*
* test("renders component", async () => {
* const { alepha, getByText } = await renderWithAlepha(<MyComponent />);
*
* expect(getByText("Hello")).toBeDefined();
* });
* ```
*
* @example
* ```tsx
* // With custom Alepha configuration
* import { renderWithAlepha } from "alepha/react/testing";
* import { MyService, MockService } from "./services";
*
* test("renders with mocked service", async () => {
* const alepha = Alepha.create().with({ provide: MyService, use: MockService });
*
* const { getByText } = await renderWithAlepha(<MyComponent />, { alepha });
*
* expect(getByText("Mocked")).toBeDefined();
* });
* ```
*
* @example
* ```tsx
* // With UI framework provider
* import { renderWithAlepha } from "alepha/react/testing";
* import { ThemeProvider } from "my-ui-library";
*
* test("renders themed component", async () => {
* const { getByRole } = await renderWithAlepha(
* <Button>Click me</Button>,
* { wrapper: ThemeProvider }
* );
*
* expect(getByRole("button")).toBeDefined();
* });
* ```
*/
declare const renderWithAlepha: (element: ReactElement, options?: RenderWithAlephaOptions) => Promise<RenderWithAlephaResult>;
/**
* Synchronous version of renderWithAlepha for cases where you don't need to await.
* Note: If autoStart is true (default), you should use the async version instead.
*
* @param element - The React element to render
* @param options - Render options (autoStart defaults to false)
* @returns The render result with the Alepha instance
*/
declare const renderWithAlephaSync: (element: ReactElement, options?: RenderWithAlephaOptions) => RenderWithAlephaResult;
//#endregion
//#region ../../src/react/testing/setup.d.ts
/**
* Setup jsdom mocks required for testing React components that use browser APIs.
* This includes mocks needed by Mantine UI components and other common browser APIs.
*
* Call this in your test setup (e.g., `beforeAll`) before rendering any components.
*
* @example
* ```typescript
* import { setupJsdomMocks } from "alepha/react/testing";
*
* beforeAll(() => {
* setupJsdomMocks();
* });
* ```
*/
declare const setupJsdomMocks: () => void;
/**
* Type declarations for mocked APIs.
*/
declare global {
interface Window {
ResizeObserver: typeof ResizeObserver;
IntersectionObserver: typeof IntersectionObserver;
}
}
//#endregion
//#region ../../src/react/testing/index.d.ts
/**
* Testing utilities for Alepha React applications.
*
* **Features:**
* - `renderWithAlepha()` - Render components with Alepha context
* - `fillForm()` / `submitForm()` - Form testing helpers
* - `setupJsdomMocks()` - Mock browser APIs for jsdom
*
* @module alepha.react.testing
*
* @example
* ```tsx
* import { renderWithAlepha, fillForm, submitForm, setupJsdomMocks } from "alepha/react/testing";
*
* // Setup mocks before tests
* beforeAll(() => {
* setupJsdomMocks();
* });
*
* test("form submission", async () => {
* const { alepha, screen } = renderWithAlepha(<MyForm />);
*
* // Fill form fields by their schema keys
* await fillForm(screen, "my-form", { name: "Alice", age: 30 });
*
* // Submit and wait for handler
* await submitForm(screen);
* });
* ```
*/
declare const AlephaReactTesting: import("alepha").Service<import("alepha").Module>;
//#endregion
export { AlephaReactTesting, FillFormOptions, RenderWithAlephaOptions, RenderWithAlephaResult, SubmitFormOptions, fillField, fillForm, renderWithAlepha, renderWithAlephaSync, resetForm, setupJsdomMocks, submitForm, toggleSwitch, waitForFormSubmit };
//# sourceMappingURL=index.d.ts.map