Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
feat(ct): solid set props (#16813)
sand4rt8d4a94bfd378
diff --git a/packages/playwright-ct-solid/registerSource.mjs b/packages/playwright-ct-solid/registerSource.mjsindex 682801de08..88a40b363f 100644--- a/packages/playwright-ct-solid/registerSource.mjs+++ b/packages/playwright-ct-solid/registerSource.mjs@@ -17,10 +17,10 @@// @ts-check// This file is injected into the registry as text, no dependencies are allowed.-import { render as solidRender } from 'solid-js/web';+import { render as solidRender, createComponent } from 'solid-js/web';/** @typedef {import('../playwright-test/types/component').Component} Component */-/** @typedef {import('solid-js').JSX.Element} FrameworkComponent */+/** @typedef {() => import('solid-js').JSX.Element} FrameworkComponent *//** @type {Map<string, FrameworkComponent>} */const registry = new Map();@@ -48,15 +48,13 @@ function render(component) {}}- if (!componentFunc && component.type[0].toUpperCase() === component.type[0])+ if (!componentFunc)throw new Error(`Unregistered component: ${component.type}. Following components are registered: ${[...registry.keys()]}`);- const componentFuncOrString = componentFunc || component.type;-if (component.kind !== 'jsx')throw new Error('Object mount notation is not supported');- return componentFuncOrString;+ return createComponent(componentFunc, component.props);}window.playwrightMount = async (component, rootElement, hooksConfig) => {diff --git a/tests/components/ct-solid/src/components/Button.tsx b/tests/components/ct-solid/src/components/Button.tsxindex a3b37db845..564a455861 100644--- a/tests/components/ct-solid/src/components/Button.tsx+++ b/tests/components/ct-solid/src/components/Button.tsx@@ -1,3 +1,6 @@-export default function Button() {- return <button>Submit</button>+type ButtonProps = {+ title: string;+}+export default function Button(props: ButtonProps) {+ return <button>{props.title}</button>}diff --git a/tests/components/ct-solid/src/tests.spec.tsx b/tests/components/ct-solid/src/tests.spec.tsxindex 95827a2939..a8b6cbefee 100644--- a/tests/components/ct-solid/src/tests.spec.tsx+++ b/tests/components/ct-solid/src/tests.spec.tsx@@ -3,7 +3,7 @@ import Button from './components/Button';test.use({ viewport: { width: 500, height: 500 } });-test('should work', async ({ mount }) => {- const component = await mount(<Button />);+test('props should work', async ({ mount }) => {+ const component = await mount(<Button title="Submit" />);await expect(component).toContainText('Submit');});