import { html as litHtml, type TemplateResult, type RenderOptions } from 'lit-html'; /** * Type alias for a template that can be rendered by the fixture function. * * @example * ```ts * test('renders lit template', async ({ assert }) => { * const el = await fixture(html``) * assert.equal(el.textContent, 'Click me') * }) * * test('renders string template', async ({ assert }) => { * const el = await fixture('
') * assert.equal(el.id, 'test') * }) * ``` */ export type TemplateTypes = string | ReturnType | TemplateResult; /** * Options for the `fixture` function. */ export interface FixtureRenderOptions extends RenderOptions { /** * By default `fixture` waits for the next animation frame to ensure * elements are upgraded and connected. Set this to `true` to skip this wait. */ noWait?: boolean; } /** * Renders a HTML string or a Lit template into a dedicated fixture container and mounts it to the DOM. * * The fixture is automatically cleaned up and removed from the DOM * when the current test or group finishes. * * @param template - A string of HTML or a `lit-html` template created using the `html` tag. * @returns A promise that resolves to the rendered DOM Element. * * @category DOM * @useWhen Rendering templates and Custom Elements into the DOM for interaction * @avoidWhen Testing pure logic or functions that do not require a DOM * * @example * ```ts * test('renders lit template', async ({ assert }) => { * const el = await fixture(html``) * assert.equal(el.textContent, 'Click me') * }) * * test('renders string template', async ({ assert }) => { * const el = await fixture('
') * assert.equal(el.id, 'test') * }) * ``` */ /** * Renders a template into a dedicated container using an explicit TestContext. * * @param template - HTML string or Lit template. * @param options - Render options. * @param context - The active TestContext instance. * @returns A promise resolving to the rendered element. * @internal */ export declare function renderFixture(template: TemplateTypes, options?: FixtureRenderOptions, context?: { cleanup: (fn: () => void) => void; }): Promise; /** * Renders a HTML string or a Lit template into a dedicated fixture container and mounts it to the DOM. * * The fixture is automatically cleaned up and removed from the DOM * when the current test or group finishes. * * @param template - A string of HTML or a `lit-html` template created using the `html` tag. * @param options - Additional options to control rendering and waiting. * @returns A promise that resolves to the rendered DOM Element. * * @category DOM * @useWhen Rendering templates and Custom Elements into the DOM for interaction * @avoidWhen Testing pure logic or functions that do not require a DOM * * @example * ```ts * test('renders lit template', async ({ assert }) => { * const el = await fixture(html``) * assert.equal(el.textContent, 'Click me') * }) * * test('renders string template', async ({ assert }) => { * const el = await fixture('
') * assert.equal(el.id, 'test') * }) * ``` */ export declare function fixture(template: TemplateTypes, options?: FixtureRenderOptions): Promise;