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
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>; }>
document
document: MockDocument;domRender
export declare function domRender(
  jsx: JSXOutput,
  opts?: {
    debug?: 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; }
(Optional)
Promise<{ document: Document; container: import("@builder.io/qwik").ClientContainer; vNode: _VNode | null; getStyles: () => Record<string, string | string[]>; }>
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 ElementFixtureConstructor
Modifiers
Description
Constructs a new instance of the ElementFixture class
Property
Modifiers
Type
Description
HTMLElement
MockDocument
HTMLElement
HTMLElement
HTMLElement
MockWindow
emulateExecutionOfQwikFuncs
export declare function emulateExecutionOfQwikFuncs(document: Document): void;Parameter
Type
Description
document
Document
void
expectDOM
export declare function expectDOM(
  actual: Element,
  expected: string,
): Promise<void>;Parameter
Type
Description
actual
Element
expected
string
Promise<void>
getTestPlatform
export declare function getTestPlatform(): TestPlatform;Returns:
TestPlatform
host
host: HTMLElement;parent
parent: HTMLElement;ssrRenderToDom
export declare function ssrRenderToDom(
  jsx: JSXOutput,
  opts?: {
    debug?: boolean;
    raw?: boolean;
  },
): Promise<{
  container: _DomContainer;
  document: Document;
  vNode: _VNode;
  getStyles: () => Record<string, string | string[]>;
}>;Parameter
Type
Description
jsx
JSXOutput
opts
{ debug?: boolean; raw?: boolean; }
(Optional)
Promise<{ container: _DomContainer; document: Document; vNode: _VNode; getStyles: () => Record<string, string | string[]>; }>
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>
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; }
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
window
window: MockWindow;