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): vue3 ts api component as slot (#18425)
sand4rtafca134c9f05
diff --git a/packages/playwright-ct-vue/registerSource.mjs b/packages/playwright-ct-vue/registerSource.mjsindex 2dfb41defd..a5955353db 100644--- a/packages/playwright-ct-vue/registerSource.mjs+++ b/packages/playwright-ct-vue/registerSource.mjs@@ -223,9 +223,12 @@ const appKey = Symbol('appKey');const wrapperKey = Symbol('wrapperKey');window.playwrightMount = async (component, rootElement, hooksConfig) => {- const wrapper = createWrapper(component);const app = createApp({- render: () => wrapper+ render: () => {+ const wrapper = createWrapper(component);+ rootElement[wrapperKey] = wrapper;+ return wrapper;+ }});setDevtoolsHook(createDevTools(), {});@@ -233,7 +236,6 @@ window.playwrightMount = async (component, rootElement, hooksConfig) => {await hook({ app, hooksConfig });const instance = app.mount(rootElement);rootElement[appKey] = app;- rootElement[wrapperKey] = wrapper;for (const hook of /** @type {any} */(window).__pw_hooks_after_mount || [])await hook({ app, hooksConfig, instance });diff --git a/tests/components/ct-vue-vite/playwright/index.ts b/tests/components/ct-vue-vite/playwright/index.tsindex c9951c0163..ff31bfe92f 100644--- a/tests/components/ct-vue-vite/playwright/index.ts+++ b/tests/components/ct-vue-vite/playwright/index.ts@@ -1,12 +1,13 @@-//@ts-check-import '../src/assets/index.css';import { beforeMount, afterMount } from '@playwright/experimental-ct-vue/hooks';+import Button from '../src/components/Button.vue';+import '../src/assets/index.css';export type HooksConfig = {route: string;}beforeMount<HooksConfig>(async ({ app, hooksConfig }) => {+ app.component('Button', Button);console.log(`Before mount: ${JSON.stringify(hooksConfig)}, app: ${!!app}`);});diff --git a/tests/components/ct-vue-vite/src/notation-vue.spec.js b/tests/components/ct-vue-vite/src/notation-vue.spec.jsindex fa5a1a51ce..03ba922f2f 100644--- a/tests/components/ct-vue-vite/src/notation-vue.spec.js+++ b/tests/components/ct-vue-vite/src/notation-vue.spec.js@@ -87,6 +87,15 @@ test('render a default slot', async ({ mount }) => {await expect(component.getByRole('strong')).toContainText('Main Content')})+test('render a component as slot', async ({ mount, page }) => {+ const component = await mount(DefaultSlot, {+ slots: {+ default: '<Button title="Submit" />',+ },+ })+ await expect(component).toContainText('Submit')+})+test('render a component with multiple slots', async ({ mount }) => {const component = await mount(DefaultSlot, {slots: {diff --git a/tests/components/ct-vue-vite/src/notation-vue.spec.ts b/tests/components/ct-vue-vite/src/notation-vue.spec.tsindex e3c7a82890..2216af825e 100644--- a/tests/components/ct-vue-vite/src/notation-vue.spec.ts+++ b/tests/components/ct-vue-vite/src/notation-vue.spec.ts@@ -88,6 +88,15 @@ test('render a default slot', async ({ mount }) => {await expect(component.getByRole('strong')).toContainText('Main Content')})+test('render a component as slot', async ({ mount, page }) => {+ const component = await mount(DefaultSlot, {+ slots: {+ default: '<Button title="Submit" />',+ },+ })+ await expect(component).toContainText('Submit')+})+test('render a component with multiple slots', async ({ mount }) => {const component = await mount(DefaultSlot, {slots: {diff --git a/tests/components/ct-vue-vite/tsconfig.app.json b/tests/components/ct-vue-vite/tsconfig.app.jsonindex be8aaad0f1..e52dda05ba 100644--- a/tests/components/ct-vue-vite/tsconfig.app.json+++ b/tests/components/ct-vue-vite/tsconfig.app.json@@ -1,6 +1,6 @@{"extends": "@vue/tsconfig/tsconfig.web.json",- "include": ["env.d.ts", "src/**/*", "src/**/*.vue"],+ "include": ["env.d.ts", "src/**/*", "src/**/*.vue", "playwright"],"exclude": ["src/**/*.spec.*/*"],"compilerOptions": {"composite": true,diff --git a/tests/components/ct-vue-vite/tsconfig.test.json b/tests/components/ct-vue-vite/tsconfig.test.jsonindex 0a7c05b4e3..96b555f526 100644--- a/tests/components/ct-vue-vite/tsconfig.test.json+++ b/tests/components/ct-vue-vite/tsconfig.test.json@@ -1,7 +1,5 @@{"extends": "./tsconfig.app.json",- "include": ["playwright"],- "exclude": [],"compilerOptions": {"composite": true,"lib": [],