From 27daa5e7b17951aa76e2b43b8a0d17d7b39a54a4 Mon Sep 17 00:00:00 2001 From: Sander Date: Fri, 20 Oct 2023 20:44:30 +0200 Subject: [PATCH] fix(ct): solid render array as child (#27715) --- packages/playwright-ct-solid/registerSource.mjs | 2 ++ tests/components/ct-solid/tests/children.spec.tsx | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/playwright-ct-solid/registerSource.mjs b/packages/playwright-ct-solid/registerSource.mjs index de401f6e4e..04efe4b59e 100644 --- a/packages/playwright-ct-solid/registerSource.mjs +++ b/packages/playwright-ct-solid/registerSource.mjs @@ -92,6 +92,8 @@ function __pwCreateComponent(component) { const children = component.children.reduce((/** @type {any[]} */ children, current) => { const child = __pwCreateChild(current); + if (Array.isArray(child)) + return child.map(grandChild => __pwCreateChild(grandChild)); if (typeof child !== 'string' || !!child.trim()) children.push(child); return children; diff --git a/tests/components/ct-solid/tests/children.spec.tsx b/tests/components/ct-solid/tests/children.spec.tsx index 59c032b030..9fa69ef932 100644 --- a/tests/components/ct-solid/tests/children.spec.tsx +++ b/tests/components/ct-solid/tests/children.spec.tsx @@ -49,8 +49,9 @@ test('render string as child', async ({ mount }) => { }); test('render array as child', async ({ mount }) => { - const component = await mount({[4,2]}); - await expect(component).toContainText('42'); + const component = await mount({[

{[4]}

,

2

]}
); + await expect(component.getByRole('heading', { level: 4 })).toHaveText('4'); + await expect(component.getByRole('paragraph')).toHaveText('2'); }); test('render number as child', async ({ mount }) => {