Skip to content

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

Revert "chore: use plugins for component testing again (#13977)" (#13998)

Pavel Feldman1bbefce9af54
diff --git a/docs/src/test-components-js.md b/docs/src/test-components-js.md
index 2f3f4f7e86..8a81598f34 100644
--- a/docs/src/test-components-js.md
+++ b/docs/src/test-components-js.md
@@ -74,7 +74,7 @@ This file makes sure `mount` fixture is typed in your tests.
### Step 2. Create a test file `src/App.spec.tsx`
```js
-import { test, expect } from '@playwright/test';
+import { test, expect } from '@playwright/experimental-ct-react';
import App from './App';
test.use({ viewport: { width: 500, height: 500 } });
diff --git a/examples/components-vue/playwright.config.ts b/examples/components-vue/playwright.config.ts
index da94fee7ed..2ea0e59130 100644
--- a/examples/components-vue/playwright.config.ts
+++ b/examples/components-vue/playwright.config.ts
@@ -1,12 +1,10 @@
-import { type PlaywrightTestConfig, devices } from '@playwright/test';
-import ct from '@playwright/experimental-ct-vue';
+import { type PlaywrightTestConfig, devices } from '@playwright/experimental-ct-vue';
const config: PlaywrightTestConfig = {
testDir: 'src',
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
reporter: 'html',
- plugins: [ct()],
use: {
trace: 'on-first-retry',
},
diff --git a/examples/components-vue/src/components/Counter.spec.ts b/examples/components-vue/src/components/Counter.spec.ts
index 11d1c6c0cb..9c5613215e 100644
--- a/examples/components-vue/src/components/Counter.spec.ts
+++ b/examples/components-vue/src/components/Counter.spec.ts
@@ -1,4 +1,4 @@
-import { test, expect } from '@playwright/test'
+import { test, expect } from '@playwright/experimental-ct-vue'
import Counter from './Counter.vue'
diff --git a/examples/components-vue/src/components/Counter.spec.tsx b/examples/components-vue/src/components/Counter.spec.tsx
index f35c482d32..60e18b1bf9 100644
--- a/examples/components-vue/src/components/Counter.spec.tsx
+++ b/examples/components-vue/src/components/Counter.spec.tsx
@@ -1,4 +1,4 @@
-import { test, expect } from '@playwright/test'
+import { test, expect } from '@playwright/experimental-ct-vue'
import Counter from './Counter.vue'
diff --git a/examples/components-vue/src/components/HelloWorld.spec.ts b/examples/components-vue/src/components/HelloWorld.spec.ts
index f15b6924e7..b041f7c258 100644
--- a/examples/components-vue/src/components/HelloWorld.spec.ts
+++ b/examples/components-vue/src/components/HelloWorld.spec.ts
@@ -1,4 +1,4 @@
-import { test, expect } from '@playwright/test'
+import { test, expect } from '@playwright/experimental-ct-vue'
import HelloWorld from './HelloWorld.vue'
diff --git a/examples/components-vue/src/components/HelloWorld.spec.tsx b/examples/components-vue/src/components/HelloWorld.spec.tsx
index 695d7a48ec..8340a011f5 100644
--- a/examples/components-vue/src/components/HelloWorld.spec.tsx
+++ b/examples/components-vue/src/components/HelloWorld.spec.tsx
@@ -1,4 +1,4 @@
-import { test, expect } from '@playwright/test'
+import { test, expect } from '@playwright/experimental-ct-vue'
import HelloWorld from './HelloWorld.vue'
diff --git a/examples/components-vue/src/components/NamedSlots.spec.ts b/examples/components-vue/src/components/NamedSlots.spec.ts
index 815e79ec27..b230b7d038 100644
--- a/examples/components-vue/src/components/NamedSlots.spec.ts
+++ b/examples/components-vue/src/components/NamedSlots.spec.ts
@@ -1,4 +1,4 @@
-import { test, expect } from '@playwright/test'
+import { test, expect } from '@playwright/experimental-ct-vue'
import NamedSlots from './NamedSlots.vue'
diff --git a/examples/components-vue/src/components/NamedSlots.spec.tsx b/examples/components-vue/src/components/NamedSlots.spec.tsx
index 7d5b5cc9e6..891f8e4f1b 100644
--- a/examples/components-vue/src/components/NamedSlots.spec.tsx
+++ b/examples/components-vue/src/components/NamedSlots.spec.tsx
@@ -1,4 +1,4 @@
-import { test, expect } from '@playwright/test'
+import { test, expect } from '@playwright/experimental-ct-vue'
import NamedSlots from './NamedSlots.vue'
diff --git a/examples/components-vue/src/components/WelcomeItem.spec.tsx b/examples/components-vue/src/components/WelcomeItem.spec.tsx
index 8598f56fb2..dfddb71dfe 100644
--- a/examples/components-vue/src/components/WelcomeItem.spec.tsx
+++ b/examples/components-vue/src/components/WelcomeItem.spec.tsx
@@ -1,4 +1,4 @@
-import { test, expect } from '@playwright/test'
+import { test, expect } from '@playwright/experimental-ct-vue'
import DocumentationIcon from './icons/IconDocumentation.vue'
import WelcomeItem from './WelcomeItem.vue'
diff --git a/examples/components-vue/tsconfig.json b/examples/components-vue/tsconfig.json
deleted file mode 100644
index 9fab5a8f8b..0000000000
--- a/examples/components-vue/tsconfig.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "compilerOptions": {
- "allowSyntheticDefaultImports": true,
- "noEmit": true,
- "jsx": "react-jsx",
- },
- "include": ["src", "playwright.d.ts", "vue.d.ts"],
-}
diff --git a/packages/html-reporter/playwright.config.ts b/packages/html-reporter/playwright.config.ts
index baa0c2e80c..cb1ed7b480 100644
--- a/packages/html-reporter/playwright.config.ts
+++ b/packages/html-reporter/playwright.config.ts
@@ -15,17 +15,16 @@
*/
import path from 'path';
-import type { PlaywrightTestConfig } from '@playwright/test';
-import { devices } from '@playwright/test';
-import ct from '@playwright/experimental-ct-react';
+import type { PlaywrightTestConfig } from '@playwright/experimental-ct-react';
+import { devices } from '@playwright/experimental-ct-react';
const config: PlaywrightTestConfig = {
testDir: 'src',
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
reporter: 'html',
- plugins: [ct({ vitePort: 3101 })],
use: {
+ vitePort: 3101,
trace: 'on-first-retry',
},
projects: [ ],
diff --git a/packages/html-reporter/playwright.d.ts b/packages/html-reporter/playwright.d.ts
deleted file mode 100644
index e288a40e04..0000000000
--- a/packages/html-reporter/playwright.d.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import '@playwright/experimental-ct-react';
diff --git a/packages/html-reporter/src/chip.spec.tsx b/packages/html-reporter/src/chip.spec.tsx
index 6dfe480eac..4306a5182f 100644
--- a/packages/html-reporter/src/chip.spec.tsx
+++ b/packages/html-reporter/src/chip.spec.tsx
@@ -15,7 +15,7 @@
*/
import React from 'react';
-import { expect, test } from '@playwright/test';
+import { expect, test } from '@playwright/experimental-ct-react';
import { AutoChip, Chip as LocalChip } from './chip';
test.use({ viewport: { width: 500, height: 500 } });
diff --git a/packages/html-reporter/src/headerView.spec.tsx b/packages/html-reporter/src/headerView.spec.tsx
index c853d45801..12ac7b903c 100644
--- a/packages/html-reporter/src/headerView.spec.tsx
+++ b/packages/html-reporter/src/headerView.spec.tsx
@@ -15,7 +15,7 @@
*/
import React from 'react';
-import { test, expect } from '@playwright/test';
+import { test, expect } from '@playwright/experimental-ct-react';
import { HeaderView } from './headerView';
test.use({ viewport: { width: 720, height: 200 } });
diff --git a/packages/html-reporter/src/imageDiffView.spec.tsx b/packages/html-reporter/src/imageDiffView.spec.tsx
index 317ceb30d6..bfd622d45d 100644
--- a/packages/html-reporter/src/imageDiffView.spec.tsx
+++ b/packages/html-reporter/src/imageDiffView.spec.tsx
@@ -15,7 +15,7 @@
*/
import React from 'react';
-import { test, expect } from '@playwright/test';
+import { test, expect } from '@playwright/experimental-ct-react';
import type { ImageDiff } from './imageDiffView';
import { ImageDiffView } from './imageDiffView';
diff --git a/packages/html-reporter/src/testCaseView.spec.tsx b/packages/html-reporter/src/testCaseView.spec.tsx
index 1274977d9b..4dedfecc0a 100644
--- a/packages/html-reporter/src/testCaseView.spec.tsx
+++ b/packages/html-reporter/src/testCaseView.spec.tsx
@@ -15,7 +15,7 @@
*/
import React from 'react';
-import { test, expect } from '@playwright/test';
+import { test, expect } from '@playwright/experimental-ct-react';
import { TestCaseView } from './testCaseView';
import type { TestCase, TestResult } from '../../playwright-test/src/reporters/html';
diff --git a/packages/html-reporter/tsconfig.json b/packages/html-reporter/tsconfig.json
index 75c92a2ca8..31c2e167d1 100644
--- a/packages/html-reporter/tsconfig.json
+++ b/packages/html-reporter/tsconfig.json
@@ -24,6 +24,6 @@
"playwright-test/lib/*": ["../playwright-test/src/*"],
}
},
- "include": ["src", "playwright.d.ts"],
+ "include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
diff --git a/packages/playwright-ct-react/index.d.ts b/packages/playwright-ct-react/index.d.ts
index 1f34f7bebf..76f294a34f 100644
--- a/packages/playwright-ct-react/index.d.ts
+++ b/packages/playwright-ct-react/index.d.ts
@@ -14,15 +14,27 @@
* limitations under the License.
*/
-import type { Locator, TestPlugin } from '@playwright/test';
+import type {
+ TestType,
+ PlaywrightTestArgs,
+ PlaywrightTestConfig as BasePlaywrightTestConfig,
+ PlaywrightTestOptions,
+ PlaywrightWorkerArgs,
+ PlaywrightWorkerOptions,
+ Locator,
+} from '@playwright/test';
import type { InlineConfig } from 'vite';
-declare global {
- export namespace PlaywrightTest {
- export interface TestArgs {
- mount(component: JSX.Element): Promise<Locator>;
- }
- }
+export type PlaywrightTestConfig = Omit<BasePlaywrightTestConfig, 'use'> & {
+ use?: BasePlaywrightTestConfig['use'] & { vitePort?: number, viteConfig?: InlineConfig }
+};
+
+interface ComponentFixtures {
+ mount(component: JSX.Element): Promise<Locator>;
}
-export default function(options?: { vitePort?: number, viteConfig?: InlineConfig }): TestPlugin;
+export const test: TestType<
+ PlaywrightTestArgs & PlaywrightTestOptions & ComponentFixtures,
+ PlaywrightWorkerArgs & PlaywrightWorkerOptions>;
+
+export { expect, devices } from '@playwright/test';
diff --git a/packages/playwright-ct-react/index.js b/packages/playwright-ct-react/index.js
index 421ba4ff9b..1cfa5de35b 100644
--- a/packages/playwright-ct-react/index.js
+++ b/packages/playwright-ct-react/index.js
@@ -14,14 +14,42 @@
* limitations under the License.
*/
+const { test: baseTest, expect, devices, _addRunnerPlugin } = require('@playwright/test');
+const { mount } = require('@playwright/test/lib/mount');
const path = require('path');
-module.exports = ({ viteConfig, vitePort } = {}) => {
- const { vitePlugin } = require('@playwright/test/lib/plugins/vitePlugin');
- return vitePlugin(
- 'playwright:experimental-ct-react',
+_addRunnerPlugin(() => {
+ // Only fetch upon request to avoid resolution in workers.
+ const { createPlugin } = require('@playwright/test/lib/plugins/vitePlugin');
+ return createPlugin(
path.join(__dirname, 'registerSource.mjs'),
- () => require('@vitejs/plugin-react')(),
- viteConfig,
- vitePort);
-};
+ () => require('@vitejs/plugin-react')());
+});
+
+const test = baseTest.extend({
+ _workerPage: [async ({ browser }, use) => {
+ const page = await browser._wrapApiCall(async () => {
+ const page = await browser.newPage();
+ await page.addInitScript('navigator.serviceWorker.register = () => {}');
+ return page;
+ });
+ await use(page);
+ }, { scope: 'worker' }],
+
+ context: async ({ page }, use) => {
+ await use(page.context());
+ },
+
+ page: async ({ _workerPage }, use) => {
+ await use(_workerPage);
+ },
+
+ mount: async ({ page, baseURL, viewport }, use) => {
+ await use(async (component, options) => {
+ const selector = await mount(page, component, options, baseURL, viewport);
+ return page.locator(selector);
+ });
+ },
+});
+
+module.exports = { test, expect, devices };
diff --git a/packages/playwright-ct-svelte/index.d.ts b/packages/playwright-ct-svelte/index.d.ts
index bc9eac0c8a..479d70de17 100644
--- a/packages/playwright-ct-svelte/index.d.ts
+++ b/packages/playwright-ct-svelte/index.d.ts
@@ -14,19 +14,31 @@
* limitations under the License.
*/
-import type { Locator, TestPlugin } from '@playwright/test';
+import type {
+ TestType,
+ PlaywrightTestArgs,
+ PlaywrightTestConfig as BasePlaywrightTestConfig,
+ PlaywrightTestOptions,
+ PlaywrightWorkerArgs,
+ PlaywrightWorkerOptions,
+ Locator,
+} from '@playwright/test';
import type { InlineConfig } from 'vite';
-declare global {
- export namespace PlaywrightTest {
- export interface TestArgs {
- mount(component: any, options?: {
- props?: { [key: string]: any },
- slots?: { [key: string]: any },
- on?: { [key: string]: Function },
- }): Promise<Locator>;
- }
- }
+export type PlaywrightTestConfig = Omit<BasePlaywrightTestConfig, 'use'> & {
+ use?: BasePlaywrightTestConfig['use'] & { vitePort?: number, viteConfig?: InlineConfig }
+};
+
+interface ComponentFixtures {
+ mount(component: any, options?: {
+ props?: { [key: string]: any },
+ slots?: { [key: string]: any },
+ on?: { [key: string]: Function },
+ }): Promise<Locator>;
}
-export default function(options?: { vitePort?: number, viteConfig?: InlineConfig }): TestPlugin;
+export const test: TestType<
+ PlaywrightTestArgs & PlaywrightTestOptions & ComponentFixtures,
+ PlaywrightWorkerArgs & PlaywrightWorkerOptions>;
+
+export { expect, devices } from '@playwright/test';
diff --git a/packages/playwright-ct-svelte/index.js b/packages/playwright-ct-svelte/index.js
index 82cb766cdd..ebdf48a25e 100644
--- a/packages/playwright-ct-svelte/index.js
+++ b/packages/playwright-ct-svelte/index.js
@@ -14,14 +14,42 @@
* limitations under the License.
*/
+const { test: baseTest, expect, devices, _addRunnerPlugin } = require('@playwright/test');
+const { mount } = require('@playwright/test/lib/mount');
const path = require('path');
-module.exports = ({ viteConfig, vitePort } = {}) => {
- const { vitePlugin } = require('@playwright/test/lib/plugins/vitePlugin');
- return vitePlugin(
- 'playwright:experimental-ct-svelte',
+_addRunnerPlugin(() => {
+ // Only fetch upon request to avoid resolution in workers.
+ const { createPlugin } = require('@playwright/test/lib/plugins/vitePlugin');
+ return createPlugin(
path.join(__dirname, 'registerSource.mjs'),
- () => require('@sveltejs/vite-plugin-svelte').svelte(),
- viteConfig,
- vitePort);
-};
+ () => require('@sveltejs/vite-plugin-svelte').svelte());
+});
+
+const test = baseTest.extend({
+ _workerPage: [async ({ browser }, use) => {
+ const page = await browser._wrapApiCall(async () => {
+ const page = await browser.newPage();
+ await page.addInitScript('navigator.serviceWorker.register = () => {}');
+ return page;
+ });
+ await use(page);
+ }, { scope: 'worker' }],
+
+ context: async ({ page }, use) => {
+ await use(page.context());
+ },
+
+ page: async ({ _workerPage }, use) => {
+ await use(_workerPage);
+ },
+
+ mount: async ({ page, baseURL, viewport }, use) => {
+ await use(async (component, options) => {
+ const selector = await mount(page, component, options, baseURL, viewport);
+ return page.locator(selector);
+ });
+ },
+});
+
+module.exports = { test, expect, devices };
diff --git a/packages/playwright-ct-vue/index.d.ts b/packages/playwright-ct-vue/index.d.ts
index 58660bc85b..71adb2e133 100644
--- a/packages/playwright-ct-vue/index.d.ts
+++ b/packages/playwright-ct-vue/index.d.ts
@@ -14,20 +14,32 @@
* limitations under the License.
*/
-import type { Locator, TestPlugin } from '@playwright/test';
+import type {
+ TestType,
+ PlaywrightTestArgs,
+ PlaywrightTestConfig as BasePlaywrightTestConfig,
+ PlaywrightTestOptions,
+ PlaywrightWorkerArgs,
+ PlaywrightWorkerOptions,
+ Locator,
+} from '@playwright/test';
import type { InlineConfig } from 'vite';
-declare global {
- export namespace PlaywrightTest {
- export interface TestArgs {
- mount(component: JSX.Element): Promise<Locator>;
- mount(component: any, options?: {
- props?: { [key: string]: any },
- slots?: { [key: string]: any },
- on?: { [key: string]: Function },
- }): Promise<Locator>;
- }
- }
+export type PlaywrightTestConfig = Omit<BasePlaywrightTestConfig, 'use'> & {
+ use?: BasePlaywrightTestConfig['use'] & { vitePort?: number, viteConfig?: InlineConfig }
+};
+
+interface ComponentFixtures {
+ mount(component: JSX.Element): Promise<Locator>;
+ mount(component: any, options?: {
+ props?: { [key: string]: any },
+ slots?: { [key: string]: any },
+ on?: { [key: string]: Function },
+ }): Promise<Locator>;
}
-export default function(options?: { vitePort?: number, viteConfig?: InlineConfig }): TestPlugin;
+export const test: TestType<
+ PlaywrightTestArgs & PlaywrightTestOptions & ComponentFixtures,
+ PlaywrightWorkerArgs & PlaywrightWorkerOptions>;
+
+export { expect, devices } from '@playwright/test';
diff --git a/packages/playwright-ct-vue/index.js b/packages/playwright-ct-vue/index.js
index 645b0622fa..f69856f172 100644
--- a/packages/playwright-ct-vue/index.js
+++ b/packages/playwright-ct-vue/index.js
@@ -14,14 +14,42 @@
* limitations under the License.
*/
+const { test: baseTest, expect, devices, _addRunnerPlugin } = require('@playwright/test');
+const { mount } = require('@playwright/test/lib/mount');
const path = require('path');
-module.exports = ({ viteConfig, vitePort } = {}) => {
- const { vitePlugin } = require('@playwright/test/lib/plugins/vitePlugin');
- return vitePlugin(
- 'playwright:experimental-ct-vue',
+_addRunnerPlugin(() => {
+ // Only fetch upon request to avoid resolution in workers.
+ const { createPlugin } = require('@playwright/test/lib/plugins/vitePlugin');
+ return createPlugin(
path.join(__dirname, 'registerSource.mjs'),
- () => require('@vitejs/plugin-vue')(),
- viteConfig,
- vitePort);
-};
+ () => require('@vitejs/plugin-vue')());
+});
+
+const test = baseTest.extend({
+ _workerPage: [async ({ browser }, use) => {
+ const page = await browser._wrapApiCall(async () => {
+ const page = await browser.newPage();
+ await page.addInitScript('navigator.serviceWorker.register = () => {}');
+ return page;
+ });
+ await use(page);
+ }, { scope: 'worker' }],
+
+ context: async ({ page }, use) => {
+ await use(page.context());
+ },
+
+ page: async ({ _workerPage }, use) => {
+ await use(_workerPage);
+ },
+
+ mount: async ({ page, baseURL, viewport }, use) => {
+ await use(async (component, options) => {
+ const selector = await mount(page, component, options, baseURL, viewport);
+ return page.locator(selector);
+ });
+ },
+});
+
+module.exports = { test, expect, devices };
diff --git a/packages/playwright-test/package.json b/packages/playwright-test/package.json
index fc29b82f72..798e24989d 100644
--- a/packages/playwright-test/package.json
+++ b/packages/playwright-test/package.json
@@ -18,6 +18,7 @@
"./lib/ci": "./lib/ci.js",
"./lib/cli": "./lib/cli.js",
"./lib/experimentalLoader": "./lib/experimentalLoader.js",
+ "./lib/mount": "./lib/mount.js",
"./lib/plugins": "./lib/plugins/index.js",
"./lib/plugins/vitePlugin": "./lib/plugins/vitePlugin.js",
"./reporter": "./reporter.js"
diff --git a/packages/playwright-test/src/loader.ts b/packages/playwright-test/src/loader.ts
index e51d48025d..46b967b4d6 100644
--- a/packages/playwright-test/src/loader.ts
+++ b/packages/playwright-test/src/loader.ts
@@ -123,17 +123,13 @@ export class Loader {
if (config.snapshotDir !== undefined)
config.snapshotDir = path.resolve(configDir, config.snapshotDir);
- const resolvedPlugins = await Promise.all((config.plugins || []).map(async plugin => {
+ config.plugins = await Promise.all((config.plugins || []).map(async plugin => {
if (typeof plugin === 'string')
return (await this._requireOrImportDefaultObject(resolveScript(plugin, configDir))) as TestPlugin;
- if (Array.isArray(plugin)) {
- const func = await this._requireOrImportDefaultFunction(resolveScript(plugin[0], configDir), false);
- plugin = func(plugin[1]) as TestPlugin;
- }
return plugin;
}));
- for (const plugin of resolvedPlugins) {
+ for (const plugin of config.plugins || []) {
if (!plugin.fixtures)
continue;
if (typeof plugin.fixtures === 'string')
@@ -159,7 +155,7 @@ export class Loader {
this._fullConfig.updateSnapshots = takeFirst(config.updateSnapshots, baseFullConfig.updateSnapshots);
this._fullConfig.workers = takeFirst(config.workers, baseFullConfig.workers);
this._fullConfig.webServer = takeFirst(config.webServer, baseFullConfig.webServer);
- this._fullConfig._plugins = takeFirst(resolvedPlugins, baseFullConfig._plugins);
+ this._fullConfig._plugins = takeFirst(config.plugins, baseFullConfig._plugins);
this._fullConfig.metadata = takeFirst(config.metadata, baseFullConfig.metadata);
this._fullConfig.projects = (config.projects || [config]).map(p => this._resolveProject(config, this._fullConfig, p, throwawayArtifactsPath));
}
diff --git a/packages/playwright-test/src/plugins/vitePlugin.ts b/packages/playwright-test/src/plugins/vitePlugin.ts
index 49b69f0d77..5708fbc835 100644
--- a/packages/playwright-test/src/plugins/vitePlugin.ts
+++ b/packages/playwright-test/src/plugins/vitePlugin.ts
@@ -14,57 +14,131 @@
* limitations under the License.
*/
-import type { InlineConfig, Plugin } from 'vite';
+import fs from 'fs';
import type { Suite } from '../../types/testReporter';
-import type { Fixtures, FullConfig, Locator, Page, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, TestPlugin } from '../types';
+import path from 'path';
+import type { InlineConfig, Plugin, PreviewServer } from 'vite';
+import type { TestRunnerPlugin } from '.';
+import { parse, traverse, types as t } from '../babelBundle';
+import type { ComponentInfo } from '../tsxTransform';
+import { collectComponentUsages, componentInfo } from '../tsxTransform';
+import type { FullConfig } from '../types';
-import { mount } from '../mount';
+let previewServer: PreviewServer;
-export function vitePlugin(
- name: string,
+export function createPlugin(
registerSourceFile: string,
- frameworkPluginFactory: () => Plugin,
- viteConfig: InlineConfig = {},
- vitePort: number = 3100): TestPlugin {
-
- let teardownVite: () => Promise<void>;
+ frameworkPluginFactory: () => Plugin): TestRunnerPlugin {
+ let configDir: string;
return {
- name,
+ name: 'playwright-vite-plugin',
setup: async (config: FullConfig, configDirectory: string, suite: Suite) => {
- teardownVite = await require('./vitePluginSetup').setup(registerSourceFile, frameworkPluginFactory, configDirectory, suite, viteConfig, vitePort);
+ const use = config.projects[0].use as any;
+ const viteConfig: InlineConfig = use.viteConfig || {};
+ const port = use.vitePort || 3100;
+
+ configDir = configDirectory;
+
+ process.env.PLAYWRIGHT_TEST_BASE_URL = `http://localhost:${port}/playwright/index.html`;
+
+ viteConfig.root = viteConfig.root || configDir;
+ viteConfig.plugins = viteConfig.plugins || [
+ frameworkPluginFactory()
+ ];
+ const files = new Set<string>();
+ for (const project of suite.suites) {
+ for (const file of project.suites)
+ files.add(file.location!.file);
+ }
+ const registerSource = await fs.promises.readFile(registerSourceFile, 'utf-8');
+ viteConfig.plugins.push(vitePlugin(registerSource, [...files]));
+ viteConfig.configFile = viteConfig.configFile || false;
+ viteConfig.define = viteConfig.define || {};
+ viteConfig.define.__VUE_PROD_DEVTOOLS__ = true;
+ viteConfig.css = viteConfig.css || {};
+ viteConfig.css.devSourcemap = true;
+ viteConfig.preview = { port };
+ viteConfig.build = {
+ target: 'esnext',
+ minify: false,
+ rollupOptions: {
+ treeshake: false,
+ input: {
+ index: path.join(viteConfig.root, 'playwright', 'index.html')
+ },
+ },
+ sourcemap: true,
+ outDir: viteConfig?.build?.outDir || path.join(viteConfig.root, './dist-pw/')
+ };
+ const { build, preview } = require('vite');
+ await build(viteConfig);
+ previewServer = await preview(viteConfig);
},
teardown: async () => {
- await teardownVite();
+ await new Promise<void>((f, r) => previewServer.httpServer.close(err => {
+ if (err)
+ r(err);
+ else
+ f();
+ }));
},
-
- fixtures
};
}
-const fixtures: Fixtures<PlaywrightTestArgs & PlaywrightTestOptions & { mount: (component: any, options: any) => Promise<Locator> }, PlaywrightWorkerArgs & { _workerPage: Page }> = {
- _workerPage: [async ({ browser }, use) => {
- const page = await (browser as any)._wrapApiCall(async () => {
- const page = await browser.newPage();
- await page.addInitScript('navigator.serviceWorker.register = () => {}');
- return page;
- });
- await use(page);
- }, { scope: 'worker' }],
-
- context: async ({ page }, use) => {
- await use(page.context());
- },
-
- page: async ({ _workerPage }, use) => {
- await use(_workerPage);
- },
-
- mount: async ({ page, viewport }, use) => {
- await use(async (component, options) => {
- const selector = await mount(page, component, options, process.env.PLAYWRIGHT_VITE_PLUGIN_GALLERY!, viewport || { width: 1280, height: 720 });
- return page.locator(selector);
- });
- },
-};
+const imports: Map<string, ComponentInfo> = new Map();
+
+function vitePlugin(registerSource: string, files: string[]): Plugin {
+ return {
+ name: 'playwright:component-index',
+
+ configResolved: async config => {
+
+ for (const file of files) {
+ const text = await fs.promises.readFile(file, 'utf-8');
+ const ast = parse(text, { errorRecovery: true, plugins: ['typescript', 'jsx'], sourceType: 'module' });
+ const components = collectComponentUsages(ast);
+
+ traverse(ast, {
+ enter: p => {
+ if (t.isImportDeclaration(p.node)) {
+ const importNode = p.node;
+ if (!t.isStringLiteral(importNode.source))
+ return;
+
+ for (const specifier of importNode.specifiers) {
+ if (!components.names.has(specifier.local.name))
+ continue;
+ if (t.isImportNamespaceSpecifier(specifier))
+ continue;
+ const info = componentInfo(specifier, importNode.source.value, file);
+ imports.set(info.fullName, info);
+ }
+ }
+ }
+ });
+ }
+ },
+
+ transform: async (content, id) => {
+ if (!id.endsWith('playwright/index.ts') && !id.endsWith('playwright/index.tsx') && !id.endsWith('playwright/index.js'))
+ return;
+
+ const folder = path.dirname(id);
+ const lines = [content, ''];
+ lines.push(registerSource);
+
+ for (const [alias, value] of imports) {
+ const importPath = value.isModuleOrAlias ? value.importPath : './' + path.relative(folder, value.importPath).replace(/\\/g, '/');
+ if (value.importedName)
+ lines.push(`import { ${value.importedName} as ${alias} } from '${importPath}';`);
+ else
+ lines.push(`import ${alias} from '${importPath}';`);
+ }
+
+ lines.push(`register({ ${[...imports.keys()].join(',\n ')} });`);
+ return lines.join('\n');
+ },
+ };
+}
diff --git a/packages/playwright-test/src/plugins/vitePluginSetup.ts b/packages/playwright-test/src/plugins/vitePluginSetup.ts
deleted file mode 100644
index 6a699b3b7a..0000000000
--- a/packages/playwright-test/src/plugins/vitePluginSetup.ts
+++ /dev/null
@@ -1,129 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import type { Suite } from '../../types/testReporter';
-import type { InlineConfig, Plugin } from 'vite';
-import type { ComponentInfo } from '../tsxTransform';
-
-import fs from 'fs';
-import path from 'path';
-import { parse, traverse, types as t } from '../babelBundle';
-import { collectComponentUsages, componentInfo } from '../tsxTransform';
-
-const { build, preview } = require('vite') as typeof import('vite');
-
-export const setup = async (registerSourceFile: string, frameworkPluginFactory: () => Plugin, configDirectory: string, suite: Suite, viteConfig: InlineConfig, vitePort: number) => {
- process.env.PLAYWRIGHT_VITE_PLUGIN_GALLERY = `http://localhost:${vitePort}/playwright/index.html`;
-
- viteConfig.root = viteConfig.root || configDirectory;
- viteConfig.plugins = viteConfig.plugins || [
- frameworkPluginFactory()
- ];
- const files = new Set<string>();
- for (const project of suite.suites) {
- for (const file of project.suites)
- files.add(file.location!.file);
- }
- const registerSource = await fs.promises.readFile(registerSourceFile, 'utf-8');
- viteConfig.plugins.push(generateGalleryPlugin(registerSource, [...files]));
- viteConfig.configFile = viteConfig.configFile || false;
- viteConfig.define = viteConfig.define || {};
- viteConfig.define.__VUE_PROD_DEVTOOLS__ = true;
- viteConfig.css = viteConfig.css || {};
- viteConfig.css.devSourcemap = true;
- viteConfig.preview = { port: vitePort };
- viteConfig.build = {
- target: 'esnext',
- minify: false,
- rollupOptions: {
- treeshake: false,
- input: {
- index: path.join(viteConfig.root, 'playwright', 'index.html')
- },
- },
- sourcemap: true,
- outDir: viteConfig?.build?.outDir || path.join(viteConfig.root, './dist-pw/')
- };
-
- await build(viteConfig);
- const previewServer = await preview(viteConfig);
-
- const teardown = async () => {
- await new Promise<void>((f, r) => previewServer.httpServer.close(err => {
- if (err)
- r(err);
- else
- f();
- }));
- };
- return teardown;
-};
-
-const imports: Map<string, ComponentInfo> = new Map();
-
-function generateGalleryPlugin(registerSource: string, files: string[]): Plugin {
- return {
- name: 'playwright:component-index',
-
- configResolved: async config => {
-
- for (const file of files) {
- const text = await fs.promises.readFile(file, 'utf-8');
- const ast = parse(text, { errorRecovery: true, plugins: ['typescript', 'jsx'], sourceType: 'module' });
- const components = collectComponentUsages(ast);
-
- traverse(ast, {
- enter: p => {
- if (t.isImportDeclaration(p.node)) {
- const importNode = p.node;
- if (!t.isStringLiteral(importNode.source))
- return;
-
- for (const specifier of importNode.specifiers) {
- if (!components.names.has(specifier.local.name))
- continue;
- if (t.isImportNamespaceSpecifier(specifier))
- continue;
- const info = componentInfo(specifier, importNode.source.value, file);
- imports.set(info.fullName, info);
- }
- }
- }
- });
- }
- },
-
- transform: async (content, id) => {
- if (!id.endsWith('playwright/index.ts') && !id.endsWith('playwright/index.tsx') && !id.endsWith('playwright/index.js'))
- return;
-
- const folder = path.dirname(id);
- const lines = [content, ''];
- lines.push(registerSource);
-
- for (const [alias, value] of imports) {
- const importPath = value.isModuleOrAlias ? value.importPath : './' + path.relative(folder, value.importPath).replace(/\\/g, '/');
- if (value.importedName)
- lines.push(`import { ${value.importedName} as ${alias} } from '${importPath}';`);
- else
- lines.push(`import ${alias} from '${importPath}';`);
- }
-
- lines.push(`register({ ${[...imports.keys()].join(',\n ')} });`);
- return lines.join('\n');
- },
- };
-}
diff --git a/packages/playwright-test/types/test.d.ts b/packages/playwright-test/types/test.d.ts
index a85df37363..785601d556 100644
--- a/packages/playwright-test/types/test.d.ts
+++ b/packages/playwright-test/types/test.d.ts
@@ -370,8 +370,9 @@ type LiteralUnion<T extends U, U = string> = T | (U & { zz_IGNORE_ME?: never });
*
*/
export interface TestPlugin {
- name: string;
fixtures?: Fixtures;
+ name: string;
+
/**
* @param config
* @param configDir
@@ -474,7 +475,7 @@ interface TestConfig {
*
*/
webServer?: TestConfigWebServer;
- plugins?: (TestPlugin | string | [string, any])[],
+ plugins?: TestPlugin[],
/**
* Configuration for the `expect` assertion library. Learn more about [various timeouts](https://playwright.dev/docs/test-timeouts).
*
@@ -2619,7 +2620,7 @@ export type VideoMode = 'off' | 'on' | 'retain-on-failure' | 'on-first-retry';
* ```
*
*/
-export interface PlaywrightTestOptions extends PlaywrightTest.TestOptions {
+export interface PlaywrightTestOptions {
/**
* Whether to automatically download all the attachments. Defaults to `true` where all the downloads are accepted.
*/
@@ -2807,7 +2808,7 @@ export interface PlaywrightWorkerArgs {
* [fixtures.context](https://playwright.dev/docs/api/class-fixtures#fixtures-context) and
* [fixtures.page](https://playwright.dev/docs/api/class-fixtures#fixtures-page).
*/
-export interface PlaywrightTestArgs extends PlaywrightTest.TestArgs {
+export interface PlaywrightTestArgs {
/**
* Isolated [BrowserContext] instance, created for each test. Since contexts are isolated between each other, every test
* gets a fresh environment, even when multiple tests run in a single [Browser] for maximum efficiency.
@@ -2925,12 +2926,6 @@ declare global {
export namespace PlaywrightTest {
export interface Matchers<R, T = unknown> {
}
-
- export interface TestArgs {
- }
-
- export interface TestOptions {
- }
}
}
// --- ENDGLOBAL ---
diff --git a/packages/web/playwright.config.ts b/packages/web/playwright.config.ts
index 098099fb80..19c070ef95 100644
--- a/packages/web/playwright.config.ts
+++ b/packages/web/playwright.config.ts
@@ -14,17 +14,16 @@
* limitations under the License.
*/
-import type { PlaywrightTestConfig } from '@playwright/test';
-import { devices } from '@playwright/test';
-import ct from '@playwright/experimental-ct-react';
+import type { PlaywrightTestConfig } from '@playwright/experimental-ct-react';
+import { devices } from '@playwright/experimental-ct-react';
const config: PlaywrightTestConfig = {
testDir: 'src',
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
reporter: 'html',
- plugins: [ct({ vitePort: 3102 })],
use: {
+ vitePort: 3102,
trace: 'on-first-retry',
},
projects: [
diff --git a/packages/web/playwright.d.ts b/packages/web/playwright.d.ts
deleted file mode 100644
index e288a40e04..0000000000
--- a/packages/web/playwright.d.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import '@playwright/experimental-ct-react';
diff --git a/packages/web/src/components/expandable.spec.tsx b/packages/web/src/components/expandable.spec.tsx
index 1c260cb25e..ad69f33aed 100644
--- a/packages/web/src/components/expandable.spec.tsx
+++ b/packages/web/src/components/expandable.spec.tsx
@@ -15,7 +15,7 @@
*/
import React from 'react';
-import { expect, test } from '@playwright/test';
+import { expect, test } from '@playwright/experimental-ct-react';
import { Expandable } from './expandable';
test.use({ viewport: { width: 500, height: 500 } });
diff --git a/packages/web/src/components/source.spec.tsx b/packages/web/src/components/source.spec.tsx
index 4b5bc95559..ee2f8b2f18 100644
--- a/packages/web/src/components/source.spec.tsx
+++ b/packages/web/src/components/source.spec.tsx
@@ -15,7 +15,7 @@
*/
import React from 'react';
-import { expect, test } from '@playwright/test';
+import { expect, test } from '@playwright/experimental-ct-react';
import { Source } from './source';
test.use({ viewport: { width: 500, height: 500 } });
diff --git a/packages/web/src/components/splitView.spec.tsx b/packages/web/src/components/splitView.spec.tsx
index 0d5c6db04d..1a302b93dd 100644
--- a/packages/web/src/components/splitView.spec.tsx
+++ b/packages/web/src/components/splitView.spec.tsx
@@ -15,7 +15,7 @@
*/
import React from 'react';
-import { expect, test } from '@playwright/test';
+import { expect, test } from '@playwright/experimental-ct-react';
import { SplitView } from './splitView';
test.use({ viewport: { width: 500, height: 500 } });
diff --git a/packages/web/tsconfig.json b/packages/web/tsconfig.json
deleted file mode 100644
index 349790399c..0000000000
--- a/packages/web/tsconfig.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "compilerOptions": {
- "allowSyntheticDefaultImports": true,
- "noEmit": true,
- "jsx": "react-jsx",
- },
- "include": ["src", "playwright.d.ts"],
-}
diff --git a/tests/components/.gitignore b/tests/components/.gitignore
index cb47598978..483a9c42c3 100644
--- a/tests/components/.gitignore
+++ b/tests/components/.gitignore
@@ -1,2 +1 @@
-package-lock.json
-dist-pw
\ No newline at end of file
+package-lock.json
\ No newline at end of file
diff --git a/tests/components/ct-react-vite/playwright.config.ts b/tests/components/ct-react-vite/playwright.config.ts
index 26e983b40b..44fa94f4fa 100644
--- a/tests/components/ct-react-vite/playwright.config.ts
+++ b/tests/components/ct-react-vite/playwright.config.ts
@@ -14,15 +14,13 @@
* limitations under the License.
*/
-import { type PlaywrightTestConfig, devices } from '@playwright/test';
-import ct from '@playwright/experimental-ct-react';
+import { type PlaywrightTestConfig, devices } from '@playwright/experimental-ct-react';
const config: PlaywrightTestConfig = {
testDir: 'src',
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
reporter: 'html',
- plugins: [ct()],
use: {
trace: 'on-first-retry',
},
diff --git a/tests/components/ct-react-vite/playwright.d.ts b/tests/components/ct-react-vite/playwright.d.ts
deleted file mode 100644
index e288a40e04..0000000000
--- a/tests/components/ct-react-vite/playwright.d.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import '@playwright/experimental-ct-react';
diff --git a/tests/components/ct-react-vite/src/App.spec.tsx b/tests/components/ct-react-vite/src/App.spec.tsx
index f15e7c1a03..e920f642b9 100644
--- a/tests/components/ct-react-vite/src/App.spec.tsx
+++ b/tests/components/ct-react-vite/src/App.spec.tsx
@@ -1,4 +1,4 @@
-import { test, expect } from '@playwright/test';
+import { test, expect } from '@playwright/experimental-ct-react';
import App from './App';
test.use({ viewport: { width: 500, height: 500 } });
diff --git a/tests/components/ct-react-vite/tsconfig.json b/tests/components/ct-react-vite/tsconfig.json
index 56e54524ca..c8bdc64082 100644
--- a/tests/components/ct-react-vite/tsconfig.json
+++ b/tests/components/ct-react-vite/tsconfig.json
@@ -16,6 +16,6 @@
"noEmit": true,
"jsx": "react-jsx"
},
- "include": ["src", "playwright.d.ts"],
+ "include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
diff --git a/tests/components/ct-react/playwright.config.ts b/tests/components/ct-react/playwright.config.ts
index 26e983b40b..44fa94f4fa 100644
--- a/tests/components/ct-react/playwright.config.ts
+++ b/tests/components/ct-react/playwright.config.ts
@@ -14,15 +14,13 @@
* limitations under the License.
*/
-import { type PlaywrightTestConfig, devices } from '@playwright/test';
-import ct from '@playwright/experimental-ct-react';
+import { type PlaywrightTestConfig, devices } from '@playwright/experimental-ct-react';
const config: PlaywrightTestConfig = {
testDir: 'src',
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
reporter: 'html',
- plugins: [ct()],
use: {
trace: 'on-first-retry',
},
diff --git a/tests/components/ct-react/playwright.d.ts b/tests/components/ct-react/playwright.d.ts
deleted file mode 100644
index e288a40e04..0000000000
--- a/tests/components/ct-react/playwright.d.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import '@playwright/experimental-ct-react';
diff --git a/tests/components/ct-react/src/App.spec.tsx b/tests/components/ct-react/src/App.spec.tsx
index 94287e831b..9d7c57d828 100644
--- a/tests/components/ct-react/src/App.spec.tsx
+++ b/tests/components/ct-react/src/App.spec.tsx
@@ -1,4 +1,4 @@
-import { test, expect } from '@playwright/test';
+import { test, expect } from '@playwright/experimental-ct-react';
import App from './App';
test.use({ viewport: { width: 500, height: 500 } });
diff --git a/tests/components/ct-react/tsconfig.json b/tests/components/ct-react/tsconfig.json
index 30f74da124..a273b0cfc0 100644
--- a/tests/components/ct-react/tsconfig.json
+++ b/tests/components/ct-react/tsconfig.json
@@ -21,7 +21,6 @@
"jsx": "react-jsx"
},
"include": [
- "src",
- "playwright.d.ts"
+ "src"
]
}
diff --git a/tests/components/ct-svelte-kit/playwright.config.ts b/tests/components/ct-svelte-kit/playwright.config.ts
index abae147417..ce93c2efee 100644
--- a/tests/components/ct-svelte-kit/playwright.config.ts
+++ b/tests/components/ct-svelte-kit/playwright.config.ts
@@ -14,16 +14,14 @@
* limitations under the License.
*/
-import type { PlaywrightTestConfig } from '@playwright/test';
+import type { PlaywrightTestConfig } from '@playwright/experimental-ct-svelte';
import { devices } from '@playwright/test';
-import ct from '@playwright/experimental-ct-svelte';
const config: PlaywrightTestConfig = {
testDir: 'src',
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
reporter: 'html',
- plugins: [ct()],
use: {
trace: 'on-first-retry',
},
diff --git a/tests/components/ct-svelte-kit/playwright.d.ts b/tests/components/ct-svelte-kit/playwright.d.ts
deleted file mode 100644
index 5133cc9329..0000000000
--- a/tests/components/ct-svelte-kit/playwright.d.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import '@playwright/experimental-ct-svelte';
diff --git a/tests/components/ct-svelte-kit/src/lib/Counter.spec.ts b/tests/components/ct-svelte-kit/src/lib/Counter.spec.ts
index 66b335924b..1e863cd250 100644
--- a/tests/components/ct-svelte-kit/src/lib/Counter.spec.ts
+++ b/tests/components/ct-svelte-kit/src/lib/Counter.spec.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { test, expect } from '@playwright/test';
+import { test, expect } from '@playwright/experimental-ct-svelte';
import Counter from './Counter.svelte';
test.use({ viewport: { width: 500, height: 500 } });
diff --git a/tests/components/ct-svelte-kit/svelte.d.ts b/tests/components/ct-svelte-kit/svelte.d.ts
deleted file mode 100644
index 0fdb59facc..0000000000
--- a/tests/components/ct-svelte-kit/svelte.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-declare module '*.svelte' {
- const value: any; // Add better type definitions here if desired.
- export default value;
-}
diff --git a/tests/components/ct-svelte-kit/tsconfig.json b/tests/components/ct-svelte-kit/tsconfig.json
deleted file mode 100644
index 596b463db6..0000000000
--- a/tests/components/ct-svelte-kit/tsconfig.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "compilerOptions": {
- "allowSyntheticDefaultImports": true,
- "noEmit": true,
- "jsx": "react-jsx",
- },
- "include": ["src", "playwright.d.ts", "selte.d.ts"],
-}
diff --git a/tests/components/ct-svelte-vite/playwright.config.ts b/tests/components/ct-svelte-vite/playwright.config.ts
index abae147417..ce93c2efee 100644
--- a/tests/components/ct-svelte-vite/playwright.config.ts
+++ b/tests/components/ct-svelte-vite/playwright.config.ts
@@ -14,16 +14,14 @@
* limitations under the License.
*/
-import type { PlaywrightTestConfig } from '@playwright/test';
+import type { PlaywrightTestConfig } from '@playwright/experimental-ct-svelte';
import { devices } from '@playwright/test';
-import ct from '@playwright/experimental-ct-svelte';
const config: PlaywrightTestConfig = {
testDir: 'src',
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
reporter: 'html',
- plugins: [ct()],
use: {
trace: 'on-first-retry',
},
diff --git a/tests/components/ct-svelte-vite/playwright.d.ts b/tests/components/ct-svelte-vite/playwright.d.ts
deleted file mode 100644
index 5133cc9329..0000000000
--- a/tests/components/ct-svelte-vite/playwright.d.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import '@playwright/experimental-ct-svelte';
diff --git a/tests/components/ct-svelte-vite/src/lib/Counter.spec.ts b/tests/components/ct-svelte-vite/src/lib/Counter.spec.ts
index 1dbfef4f8c..35a4a7dd81 100644
--- a/tests/components/ct-svelte-vite/src/lib/Counter.spec.ts
+++ b/tests/components/ct-svelte-vite/src/lib/Counter.spec.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { test, expect } from '@playwright/test';
+import { test, expect } from '@playwright/experimental-ct-svelte';
import Counter from './Counter.svelte';
test.use({ viewport: { width: 500, height: 500 } });
diff --git a/tests/components/ct-svelte-vite/tsconfig.json b/tests/components/ct-svelte-vite/tsconfig.json
index c67ff894e8..4d6c04cf0a 100644
--- a/tests/components/ct-svelte-vite/tsconfig.json
+++ b/tests/components/ct-svelte-vite/tsconfig.json
@@ -15,6 +15,6 @@
"allowJs": true,
"checkJs": true
},
- "include": ["src/**/*.d.ts", "src/**/*.ts", "src/**/*.js", "src/**/*.svelte", "playwright.d.ts"],
+ "include": ["src/**/*.d.ts", "src/**/*.ts", "src/**/*.js", "src/**/*.svelte"],
"references": [{ "path": "./tsconfig.node.json" }]
}
diff --git a/tests/components/ct-svelte/playwright.config.ts b/tests/components/ct-svelte/playwright.config.ts
index abae147417..ce93c2efee 100644
--- a/tests/components/ct-svelte/playwright.config.ts
+++ b/tests/components/ct-svelte/playwright.config.ts
@@ -14,16 +14,14 @@
* limitations under the License.
*/
-import type { PlaywrightTestConfig } from '@playwright/test';
+import type { PlaywrightTestConfig } from '@playwright/experimental-ct-svelte';
import { devices } from '@playwright/test';
-import ct from '@playwright/experimental-ct-svelte';
const config: PlaywrightTestConfig = {
testDir: 'src',
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
reporter: 'html',
- plugins: [ct()],
use: {
trace: 'on-first-retry',
},
diff --git a/tests/components/ct-svelte/playwright.d.ts b/tests/components/ct-svelte/playwright.d.ts
deleted file mode 100644
index 5133cc9329..0000000000
--- a/tests/components/ct-svelte/playwright.d.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import '@playwright/experimental-ct-svelte';
diff --git a/tests/components/ct-svelte/src/App.spec.ts b/tests/components/ct-svelte/src/App.spec.ts
index dc3d71bfdb..68223ddc06 100644
--- a/tests/components/ct-svelte/src/App.spec.ts
+++ b/tests/components/ct-svelte/src/App.spec.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { test, expect } from '@playwright/test';
+import { test, expect } from '@playwright/experimental-ct-svelte';
import App from './App.svelte';
test.use({ viewport: { width: 500, height: 500 } });
diff --git a/tests/components/ct-svelte/tsconfig.json b/tests/components/ct-svelte/tsconfig.json
deleted file mode 100644
index 7cc2aae6ce..0000000000
--- a/tests/components/ct-svelte/tsconfig.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "compilerOptions": {
- "allowSyntheticDefaultImports": true,
- "noEmit": true,
- "jsx": "react-jsx",
- },
- "include": ["src", "playwright.d.ts", "svelte.d.ts"],
-}
diff --git a/tests/components/ct-vue-cli/playwright.config.ts b/tests/components/ct-vue-cli/playwright.config.ts
index 4192cff1d5..dbf9c593bd 100644
--- a/tests/components/ct-vue-cli/playwright.config.ts
+++ b/tests/components/ct-vue-cli/playwright.config.ts
@@ -14,15 +14,13 @@
* limitations under the License.
*/
-import { type PlaywrightTestConfig, devices } from '@playwright/test';
-import ct from '@playwright/experimental-ct-vue';
+import { type PlaywrightTestConfig, devices } from '@playwright/experimental-ct-vue';
const config: PlaywrightTestConfig = {
testDir: 'src',
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
reporter: 'html',
- plugins: [ct()],
use: {
trace: 'on-first-retry',
},
diff --git a/tests/components/ct-vue-cli/playwright.d.ts b/tests/components/ct-vue-cli/playwright.d.ts
deleted file mode 100644
index 8e069208e7..0000000000
--- a/tests/components/ct-vue-cli/playwright.d.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import '@playwright/experimental-ct-vue';
diff --git a/tests/components/ct-vue-cli/src/notation-jsx.spec.tsx b/tests/components/ct-vue-cli/src/notation-jsx.spec.tsx
index 6de506735b..3ecea3cac2 100644
--- a/tests/components/ct-vue-cli/src/notation-jsx.spec.tsx
+++ b/tests/components/ct-vue-cli/src/notation-jsx.spec.tsx
@@ -1,4 +1,4 @@
-import { test, expect } from '@playwright/test'
+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'
diff --git a/tests/components/ct-vue-cli/src/notation-vue.spec.ts b/tests/components/ct-vue-cli/src/notation-vue.spec.ts
index 756b1201a3..ae611bcdaf 100644
--- a/tests/components/ct-vue-cli/src/notation-vue.spec.ts
+++ b/tests/components/ct-vue-cli/src/notation-vue.spec.ts
@@ -1,4 +1,4 @@
-import { test, expect } from '@playwright/test'
+import { test, expect } from '@playwright/experimental-ct-vue'
import Button from './components/Button.vue'
import DefaultSlot from './components/DefaultSlot.vue'
diff --git a/tests/components/ct-vue-vite/playwright.config.ts b/tests/components/ct-vue-vite/playwright.config.ts
index 4192cff1d5..dbf9c593bd 100644
--- a/tests/components/ct-vue-vite/playwright.config.ts
+++ b/tests/components/ct-vue-vite/playwright.config.ts
@@ -14,15 +14,13 @@
* limitations under the License.
*/
-import { type PlaywrightTestConfig, devices } from '@playwright/test';
-import ct from '@playwright/experimental-ct-vue';
+import { type PlaywrightTestConfig, devices } from '@playwright/experimental-ct-vue';
const config: PlaywrightTestConfig = {
testDir: 'src',
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
reporter: 'html',
- plugins: [ct()],
use: {
trace: 'on-first-retry',
},
diff --git a/tests/components/ct-vue-vite/playwright.d.ts b/tests/components/ct-vue-vite/playwright.d.ts
deleted file mode 100644
index 8e069208e7..0000000000
--- a/tests/components/ct-vue-vite/playwright.d.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import '@playwright/experimental-ct-vue';
diff --git a/tests/components/ct-vue-vite/src/notation-jsx.spec.tsx b/tests/components/ct-vue-vite/src/notation-jsx.spec.tsx
index a11d9fa9cf..4d604f5362 100644
--- a/tests/components/ct-vue-vite/src/notation-jsx.spec.tsx
+++ b/tests/components/ct-vue-vite/src/notation-jsx.spec.tsx
@@ -1,4 +1,4 @@
-import { test, expect } from '@playwright/test'
+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'
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 756b1201a3..ae611bcdaf 100644
--- a/tests/components/ct-vue-vite/src/notation-vue.spec.ts
+++ b/tests/components/ct-vue-vite/src/notation-vue.spec.ts
@@ -1,4 +1,4 @@
-import { test, expect } from '@playwright/test'
+import { test, expect } from '@playwright/experimental-ct-vue'
import Button from './components/Button.vue'
import DefaultSlot from './components/DefaultSlot.vue'
diff --git a/tests/components/ct-vue-vite/tsconfig.json b/tests/components/ct-vue-vite/tsconfig.json
deleted file mode 100644
index 53199e3d4a..0000000000
--- a/tests/components/ct-vue-vite/tsconfig.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "compilerOptions": {
- "allowSyntheticDefaultImports": true,
- "noEmit": true,
- "jsx": "react-jsx",
- },
- "include": ["src", "vue.d.ts", "playwright.d.ts"],
-}
diff --git a/tests/config/experimental.d.ts b/tests/config/experimental.d.ts
index 7eff0f5b6a..8e48c6f8a3 100644
--- a/tests/config/experimental.d.ts
+++ b/tests/config/experimental.d.ts
@@ -17030,8 +17030,9 @@ type LiteralUnion<T extends U, U = string> = T | (U & { zz_IGNORE_ME?: never });
*
*/
export interface TestPlugin {
- name: string;
fixtures?: Fixtures;
+ name: string;
+
/**
* @param config
* @param configDir
@@ -17134,7 +17135,7 @@ interface TestConfig {
*
*/
webServer?: TestConfigWebServer;
- plugins?: (TestPlugin | string | [string, any])[],
+ plugins?: TestPlugin[],
/**
* Configuration for the `expect` assertion library. Learn more about [various timeouts](https://playwright.dev/docs/test-timeouts).
*
@@ -19364,7 +19365,7 @@ export type VideoMode = 'off' | 'on' | 'retain-on-failure' | 'on-first-retry';
* ```
*
*/
-export interface PlaywrightTestOptions extends PlaywrightTest.TestOptions {
+export interface PlaywrightTestOptions {
/**
* Whether to automatically download all the attachments. Defaults to `true` where all the downloads are accepted.
*/
@@ -19552,7 +19553,7 @@ export interface PlaywrightWorkerArgs {
* [fixtures.context](https://playwright.dev/docs/api/class-fixtures#fixtures-context) and
* [fixtures.page](https://playwright.dev/docs/api/class-fixtures#fixtures-page).
*/
-export interface PlaywrightTestArgs extends PlaywrightTest.TestArgs {
+export interface PlaywrightTestArgs {
/**
* Isolated [BrowserContext] instance, created for each test. Since contexts are isolated between each other, every test
* gets a fresh environment, even when multiple tests run in a single [Browser] for maximum efficiency.
diff --git a/utils/generate_types/index.js b/utils/generate_types/index.js
index 53d13a6c88..1775b0e235 100644
--- a/utils/generate_types/index.js
+++ b/utils/generate_types/index.js
@@ -93,7 +93,7 @@ class TypesGenerator {
let overrides = await parseOverrides(overridesFile, className => {
const docClass = this.docClassForName(className);
- if (!docClass || !this.shouldGenerate(className))
+ if (!docClass)
return '';
handledClasses.add(className);
return this.writeComment(docClass.comment) + '\n';
@@ -573,7 +573,6 @@ class TypesGenerator {
'PlaywrightWorkerOptions.defaultBrowserType',
'PlaywrightWorkerArgs.playwright',
'Matchers',
- 'TestArgs',
]),
doNotExportClassNames: new Set([...assertionClasses, 'TestProject']),
includeExperimental,
diff --git a/utils/generate_types/overrides-test.d.ts b/utils/generate_types/overrides-test.d.ts
index 4231987127..40f6621fa7 100644
--- a/utils/generate_types/overrides-test.d.ts
+++ b/utils/generate_types/overrides-test.d.ts
@@ -57,14 +57,13 @@ export interface FullProject<TestArgs = {}, WorkerArgs = {}> {
type LiteralUnion<T extends U, U = string> = T | (U & { zz_IGNORE_ME?: never });
export interface TestPlugin {
- name: string;
fixtures?: Fixtures;
}
interface TestConfig {
reporter?: LiteralUnion<'list'|'dot'|'line'|'github'|'json'|'junit'|'null'|'html', string> | ReporterDescription[];
webServer?: TestConfigWebServer;
- plugins?: (TestPlugin | string | [string, any])[],
+ plugins?: TestPlugin[],
}
export interface Config<TestArgs = {}, WorkerArgs = {}> extends TestConfig {
@@ -213,7 +212,7 @@ export interface PlaywrightWorkerOptions {
export type TraceMode = 'off' | 'on' | 'retain-on-failure' | 'on-first-retry';
export type VideoMode = 'off' | 'on' | 'retain-on-failure' | 'on-first-retry';
-export interface PlaywrightTestOptions extends PlaywrightTest.TestOptions {
+export interface PlaywrightTestOptions {
acceptDownloads: boolean | undefined;
bypassCSP: boolean | undefined;
colorScheme: ColorScheme | undefined;
@@ -245,7 +244,7 @@ export interface PlaywrightWorkerArgs {
browser: Browser;
}
-export interface PlaywrightTestArgs extends PlaywrightTest.TestArgs {
+export interface PlaywrightTestArgs {
context: BrowserContext;
page: Page;
request: APIRequestContext;
@@ -318,12 +317,6 @@ declare global {
export namespace PlaywrightTest {
export interface Matchers<R, T = unknown> {
}
-
- export interface TestArgs {
- }
-
- export interface TestOptions {
- }
}
}
// --- ENDGLOBAL ---