Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test(ct): solid callbacks (#16837)

sand4rta0f19a4f2d09
diff --git a/tests/components/ct-solid/src/components/Button.tsx b/tests/components/ct-solid/src/components/Button.tsx
index 564a455861..78b0a7791f 100644
--- a/tests/components/ct-solid/src/components/Button.tsx
+++ b/tests/components/ct-solid/src/components/Button.tsx
@@ -1,6 +1,7 @@
type ButtonProps = {
title: string;
+ onClick?(props: string): void;
}
export default function Button(props: ButtonProps) {
- return <button>{props.title}</button>
+ return <button onClick={() => props.onClick?.('hello')}>{props.title}</button>
}
diff --git a/tests/components/ct-solid/src/tests.spec.tsx b/tests/components/ct-solid/src/tests.spec.tsx
index a8b6cbefee..f8a2769799 100644
--- a/tests/components/ct-solid/src/tests.spec.tsx
+++ b/tests/components/ct-solid/src/tests.spec.tsx
@@ -7,3 +7,12 @@ test('props should work', async ({ mount }) => {
const component = await mount(<Button title="Submit" />);
await expect(component).toContainText('Submit');
});
+
+test('callback should work', async ({ mount }) => {
+ const messages: string[] = []
+ const component = await mount(<Button title="Submit" onClick={data => {
+ messages.push(data)
+ }}></Button>)
+ await component.click()
+ expect(messages).toEqual(['hello'])
+})