From 24a7b60be2a45acc5e9b0c6db370832a0b80cc6a Mon Sep 17 00:00:00 2001 From: Donald Le Date: Wed, 18 Mar 2026 15:35:10 +0700 Subject: [PATCH] feat: fix types warning errors when importing from cypress component tests --- .gitignore | 10 ++++++++++ packages/cypress-ct-qwik/src/lib/mount.tsx | 21 +++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index f40ae22..65b6ed7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,9 +2,15 @@ dist /server +# Package tarballs +*.tgz + # Development node_modules +# Temp files +tmp + # Cache .cache .mf @@ -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 diff --git a/packages/cypress-ct-qwik/src/lib/mount.tsx b/packages/cypress-ct-qwik/src/lib/mount.tsx index d9da69b..bbdd8b1 100644 --- a/packages/cypress-ct-qwik/src/lib/mount.tsx +++ b/packages/cypress-ct-qwik/src/lib/mount.tsx @@ -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; + options?: { + strict?: boolean; + }; +} + +type JSXOutput = JSXNode | string | number | boolean | null | undefined | JSXOutput[]; + +export function mount(component: JSXOutput | JSXNode[] | FunctionComponent, options?: MountOptions) { const root = getContainerEl(); - const renderResultPromise = render(root, element); + const renderResultPromise = render(root, component as JSXNode | FunctionComponent); 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', };