Skip to content

Commit

Permalink
cherry-pick(#29026): test: add a props.children test
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman committed Jan 18, 2024
1 parent 50a8e4f commit 8ee2d81
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/playwright-test/playwright.ct-react.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,3 +495,23 @@ test('should normalize children', async ({ runInlineTest }) => {
expect(result.exitCode).toBe(0);
expect(result.passed).toBe(2);
});

test('should allow props children', async ({ runInlineTest }) => {
const result = await runInlineTest({
'playwright.config.ts': playwrightConfig,
'playwright/index.html': `<script type="module" src="./index.ts"></script>`,
'playwright/index.ts': ``,
'src/component.spec.tsx': `
import { test, expect } from '@playwright/experimental-ct-react';
test("renders children from props object", async ({ mount, page }) => {
const props = { children: 'test' };
await mount(<button {...props} />);
await expect(page.getByText('test')).toBeVisible();
});
`,
}, { workers: 1 });

expect(result.exitCode).toBe(0);
expect(result.passed).toBe(1);
});

0 comments on commit 8ee2d81

Please sign in to comment.