Skip to content

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

fix(ct): support components w/o mount options (#15501)

Pavel Feldmandd0eb5fb1d74
diff --git a/packages/playwright-test/src/mount.ts b/packages/playwright-test/src/mount.ts
index 22901efe3a..53970a8f04 100644
--- a/packages/playwright-test/src/mount.ts
+++ b/packages/playwright-test/src/mount.ts
@@ -76,7 +76,7 @@ export const fixtures: Fixtures<
},
};
-async function innerMount(page: Page, jsxOrType: JsxComponent | string, options?: ObjectComponentOptions): Promise<string> {
+async function innerMount(page: Page, jsxOrType: JsxComponent | string, options: ObjectComponentOptions = {}): Promise<string> {
let component: Component;
if (typeof jsxOrType === 'string')
component = { kind: 'object', type: jsxOrType, options };
diff --git a/tests/components/ct-vue-vite/src/components/Component.vue b/tests/components/ct-vue-vite/src/components/Component.vue
new file mode 100644
index 0000000000..133c8e2670
--- /dev/null
+++ b/tests/components/ct-vue-vite/src/components/Component.vue
@@ -0,0 +1,3 @@
+<template>
+ <div>test</div>
+</template>
diff --git a/tests/components/ct-vue-vite/src/notation-vue.spec.ts b/tests/components/ct-vue-vite/src/notation-vue.spec.ts
index ae611bcdaf..e1b706dcc9 100644
--- a/tests/components/ct-vue-vite/src/notation-vue.spec.ts
+++ b/tests/components/ct-vue-vite/src/notation-vue.spec.ts
@@ -3,6 +3,7 @@ import { test, expect } from '@playwright/experimental-ct-vue'
import Button from './components/Button.vue'
import DefaultSlot from './components/DefaultSlot.vue'
import NamedSlots from './components/NamedSlots.vue'
+import Component from './components/Component.vue'
test.use({ viewport: { width: 500, height: 500 } })
@@ -60,3 +61,8 @@ test('named slots should work', async ({ mount }) => {
await expect(component).toContainText('Main Content')
await expect(component).toContainText('Footer')
})
+
+test('optionless should work', async ({ mount }) => {
+ const component = await mount(Component)
+ await expect(component).toContainText('test')
+})