Skip to content

Commit 8ee2d81

Browse files
committed
cherry-pick(#29026): test: add a props.children test
1 parent 50a8e4f commit 8ee2d81

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/playwright-test/playwright.ct-react.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,3 +495,23 @@ test('should normalize children', async ({ runInlineTest }) => {
495495
expect(result.exitCode).toBe(0);
496496
expect(result.passed).toBe(2);
497497
});
498+
499+
test('should allow props children', async ({ runInlineTest }) => {
500+
const result = await runInlineTest({
501+
'playwright.config.ts': playwrightConfig,
502+
'playwright/index.html': `<script type="module" src="./index.ts"></script>`,
503+
'playwright/index.ts': ``,
504+
'src/component.spec.tsx': `
505+
import { test, expect } from '@playwright/experimental-ct-react';
506+
507+
test("renders children from props object", async ({ mount, page }) => {
508+
const props = { children: 'test' };
509+
await mount(<button {...props} />);
510+
await expect(page.getByText('test')).toBeVisible();
511+
});
512+
`,
513+
}, { workers: 1 });
514+
515+
expect(result.exitCode).toBe(0);
516+
expect(result.passed).toBe(1);
517+
});

0 commit comments

Comments
 (0)