API โ€บ @builder.io/qwik/testing

child

child: HTMLElement;

createDocument

Create emulated Document for server environment. Does not implement the full browser document and window API. This api may be removed in the future.

export declare function createDocument(opts?: MockDocumentOptions): Document;

Parameter

Type

Description

opts

MockDocumentOptions

(Optional)

Document

Edit this section

createDOM

CreatePlatform and CreateDocument

createDOM: ({ html }?: { html?: string }) =>
  Promise<{
    render: (
      jsxElement: JSXOutput,
    ) => Promise<import("@builder.io/qwik").RenderResult>;
    screen: HTMLElement;
    userEvent: (
      queryOrElement: string | Element | keyof HTMLElementTagNameMap | null,
      eventNameCamel: string | keyof WindowEventMap,
      eventPayload?: any,
    ) => Promise<void>;
  }>;

Parameter

Type

Description

{ html }

{ html?: string; }

(Optional)

Promise<{ render: (jsxElement: JSXOutput) => Promise<import("@builder.io/qwik").RenderResult>; screen: HTMLElement; userEvent: (queryOrElement: string | Element | keyof HTMLElementTagNameMap | null, eventNameCamel: string | keyof WindowEventMap, eventPayload?: any) => Promise<void>; }>

Edit this section

document

document: MockDocument;

domRender

export declare function domRender(
  jsx: JSXOutput,
  opts?: {
    debug?: boolean;
    oldSSR?: boolean;
  },
): Promise<{
  document: Document;
  container: import("@builder.io/qwik").ClientContainer;
  vNode: _VNode | null;
  getStyles: () => Record<string, string | string[]>;
}>;

Parameter

Type

Description

jsx

JSXOutput

opts

{ debug?: boolean; oldSSR?: boolean; }

(Optional)

Promise<{ document: Document; container: import("@builder.io/qwik").ClientContainer; vNode: _VNode | null; getStyles: () => Record<string, string | string[]>; }>

Edit this section

ElementFixture

Creates a simple DOM structure for testing components.

By default EntityFixture creates:

<host q:view="./component_fixture.noop">
  <child></child>
</host>
export declare class ElementFixture

Constructor

Modifiers

Description

(constructor)(options)

Constructs a new instance of the ElementFixture class

Property

Modifiers

Type

Description

child

HTMLElement

document

MockDocument

host

HTMLElement

parent

HTMLElement

superParent

HTMLElement

window

MockWindow

Edit this section

emulateExecutionOfQwikFuncs

export declare function emulateExecutionOfQwikFuncs(document: Document): void;

Parameter

Type

Description

document

Document

void

Edit this section

expectDOM

export declare function expectDOM(
  actual: Element,
  expected: string,
): Promise<void>;

Parameter

Type

Description

actual

Element

expected

string

Promise<void>

Edit this section

getTestPlatform

export declare function getTestPlatform(): TestPlatform;

Returns:

TestPlatform

Edit this section

host

host: HTMLElement;

parent

parent: HTMLElement;

ssrRenderToDom

export declare function ssrRenderToDom(
  jsx: JSXOutput,
  opts?: {
    debug?: boolean;
    oldSSR?: boolean;
    raw?: boolean;
  },
): Promise<{
  container: _DomContainer;
  document: Document;
  vNode: _VNode;
  getStyles: () => Record<string, string | string[]>;
}>;

Parameter

Type

Description

jsx

JSXOutput

opts

{ debug?: boolean; oldSSR?: boolean; raw?: boolean; }

(Optional)

Promise<{ container: _DomContainer; document: Document; vNode: _VNode; getStyles: () => Record<string, string | string[]>; }>

Edit this section

superParent

superParent: HTMLElement;

trigger

Trigger an event in unit tests on an element.

Future deprecation candidate.

export declare function trigger(
  root: Element,
  queryOrElement: string | Element | keyof HTMLElementTagNameMap | null,
  eventNameCamel: string,
  eventPayload?: any,
): Promise<void>;

Parameter

Type

Description

root

Element

queryOrElement

string | Element | keyof HTMLElementTagNameMap | null

eventNameCamel

string

eventPayload

any

(Optional)

Promise<void>

Edit this section

vnode_fromJSX

export declare function vnode_fromJSX(jsx: JSXOutput): {
  vParent: _ElementVNode;
  vNode: _VNode | null;
  document: _QDocument;
};

Parameter

Type

Description

jsx

JSXOutput

{ vParent: _ElementVNode; vNode: _VNode | null; document: _QDocument; }

Edit this section

walkJSX

export declare function walkJSX(
  jsx: JSXOutput,
  apply: {
    enter: (jsx: JSXNode) => void;
    leave: (jsx: JSXNode) => void;
    text: (text: _Stringifiable) => void;
  },
): void;

Parameter

Type

Description

jsx

JSXOutput

apply

{ enter: (jsx: JSXNode) => void; leave: (jsx: JSXNode) => void; text: (text: _Stringifiable) => void; }

void

Edit this section

window

window: MockWindow;