Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
dist
/server

# Package tarballs
*.tgz

# Development
node_modules

# Temp files
tmp

# Cache
.cache
.mf
Expand All @@ -30,6 +36,10 @@ yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

# Package manager lock files (this project uses pnpm)
package-lock.json
yarn.lock

# Editor
.idea
.DS_Store
Expand Down
21 changes: 15 additions & 6 deletions packages/cypress-ct-qwik/src/lib/mount.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
import type { JSXNode, RenderResult } from '@builder.io/qwik';
import type { JSXNode, RenderResult, FunctionComponent } from '@builder.io/qwik';
import { render } from '@builder.io/qwik';
import { getContainerEl, setupHooks } from '@cypress/mount-utils';

let destroy: () => void | undefined;
let destroy: (() => void) | undefined;

function cleanup() {
if (destroy) destroy();
}

export function mount(element: JSXNode) {
export interface MountOptions {
props?: Record<string, unknown>;
options?: {
strict?: boolean;
};
}

type JSXOutput = JSXNode | string | number | boolean | null | undefined | JSXOutput[];

export function mount(component: JSXOutput | JSXNode[] | FunctionComponent<any>, options?: MountOptions) {
const root = getContainerEl();

const renderResultPromise = render(root, element);
const renderResultPromise = render(root, component as JSXNode | FunctionComponent<any>);

Cypress.log({
name: 'mount',
message: 'Component',
consoleProps: () => {
const comp = component as { props?: unknown } | null | undefined;
return {
// // @ts-ignore protect the use of jsx functional components use ReactNode
props: element?.props,
props: comp?.props,
description: 'Mounted Qwik component',
home: 'https://github.com/qwikifiers/cypress-qwik',
};
Expand Down