chore: restore component testing options (#13910)

This commit is contained in:
Pavel Feldman 2022-05-03 14:48:46 -08:00 коммит произвёл GitHub
Родитель 29fd1d86df
Коммит 13224d1c9f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
48 изменённых файлов: 103 добавлений и 87 удалений

Просмотреть файл

@ -1,4 +1,4 @@
import { PlaywrightTestConfig, devices } from '@playwright/test';
import { type PlaywrightTestConfig, devices } from '@playwright/experimental-ct-vue';
const config: PlaywrightTestConfig = {
testDir: 'src',

Просмотреть файл

@ -1,4 +1,4 @@
import { test, expect } from '@playwright/experimental-ct-vue/test'
import { test, expect } from '@playwright/experimental-ct-vue'
import Counter from './Counter.vue'

Просмотреть файл

@ -1,4 +1,4 @@
import { test, expect } from '@playwright/experimental-ct-vue/test'
import { test, expect } from '@playwright/experimental-ct-vue'
import Counter from './Counter.vue'

Просмотреть файл

@ -1,4 +1,4 @@
import { test, expect } from '@playwright/experimental-ct-vue/test'
import { test, expect } from '@playwright/experimental-ct-vue'
import HelloWorld from './HelloWorld.vue'

Просмотреть файл

@ -1,4 +1,4 @@
import { test, expect } from '@playwright/experimental-ct-vue/test'
import { test, expect } from '@playwright/experimental-ct-vue'
import HelloWorld from './HelloWorld.vue'

Просмотреть файл

@ -1,4 +1,4 @@
import { test, expect } from '@playwright/experimental-ct-vue/test'
import { test, expect } from '@playwright/experimental-ct-vue'
import NamedSlots from './NamedSlots.vue'

Просмотреть файл

@ -1,4 +1,4 @@
import { test, expect } from '@playwright/experimental-ct-vue/test'
import { test, expect } from '@playwright/experimental-ct-vue'
import NamedSlots from './NamedSlots.vue'

Просмотреть файл

@ -1,4 +1,4 @@
import { test, expect } from '@playwright/experimental-ct-vue/test'
import { test, expect } from '@playwright/experimental-ct-vue'
import DocumentationIcon from './icons/IconDocumentation.vue'
import WelcomeItem from './WelcomeItem.vue'

Просмотреть файл

@ -14,20 +14,17 @@
* limitations under the License.
*/
import type { PlaywrightTestConfig } from '@playwright/test';
import path from 'path';
import { devices } from '@playwright/test';
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: process.env.CI ? [
['html', { open: 'never' }],
] : [
['html', { open: 'on-failure' }]
],
reporter: 'html',
use: {
vitePort: 3101,
trace: 'on-first-retry',
},
projects: [ ],

Просмотреть файл

@ -15,7 +15,7 @@
*/
import React from 'react';
import { expect, test } from '@playwright/experimental-ct-react/test';
import { expect, test } from '@playwright/experimental-ct-react';
import { AutoChip, Chip as LocalChip } from './chip';
test.use({ viewport: { width: 500, height: 500 } });

Просмотреть файл

@ -15,7 +15,7 @@
*/
import React from 'react';
import { test, expect } from '@playwright/experimental-ct-react/test';
import { test, expect } from '@playwright/experimental-ct-react';
import { HeaderView } from './headerView';
test.use({ viewport: { width: 720, height: 200 } });

Просмотреть файл

@ -15,7 +15,7 @@
*/
import React from 'react';
import { test, expect } from '@playwright/experimental-ct-react/test';
import { test, expect } from '@playwright/experimental-ct-react';
import type { ImageDiff } from './imageDiffView';
import { ImageDiffView } from './imageDiffView';

Просмотреть файл

@ -15,7 +15,7 @@
*/
import React from 'react';
import { test, expect } from '@playwright/experimental-ct-react/test';
import { test, expect } from '@playwright/experimental-ct-react';
import { TestCaseView } from './testCaseView';
import type { TestCase, TestResult } from '../../playwright-test/src/reporters/html';

Просмотреть файл

@ -4,7 +4,5 @@
!LICENSE
!register.d.ts
!register.mjs
!test.d.ts
!test.js
!vitePlugin.d.ts
!vitePlugin.js
!index.d.ts
!index.js

Просмотреть файл

@ -17,11 +17,17 @@
import type {
TestType,
PlaywrightTestArgs,
PlaywrightTestConfig as BasePlaywrightTestConfig,
PlaywrightTestOptions,
PlaywrightWorkerArgs,
PlaywrightWorkerOptions,
Locator,
} from '@playwright/test';
import type { InlineConfig } from 'vite';
export type PlaywrightTestConfig = Omit<BasePlaywrightTestConfig, 'use'> & {
use: BasePlaywrightTestConfig['use'] & { vitePort?: number, viteConfig?: InlineConfig }
};
interface ComponentFixtures {
mount(component: JSX.Element): Promise<Locator>;
@ -31,4 +37,4 @@ export const test: TestType<
PlaywrightTestArgs & PlaywrightTestOptions & ComponentFixtures,
PlaywrightWorkerArgs & PlaywrightWorkerOptions>;
export { expect } from '@playwright/test';
export { expect, devices } from '@playwright/test';

Просмотреть файл

@ -14,13 +14,16 @@
* limitations under the License.
*/
const { test: baseTest, expect, _addRunnerPlugin } = require('@playwright/test');
const { test: baseTest, expect, devices, _addRunnerPlugin } = require('@playwright/test');
const { mount } = require('@playwright/test/lib/mount');
const { createPlugin } = require('@playwright/test/lib/plugins/vitePlugin');
_addRunnerPlugin(createPlugin(
'@playwright/experimental-ct-react/register',
() => require('@vitejs/plugin-react')()));
_addRunnerPlugin(() => {
// Only fetch upon request to avoid resolution in workers.
const { createPlugin } = require('@playwright/test/lib/plugins/vitePlugin');
return createPlugin(
'@playwright/experimental-ct-react/register',
() => require('@vitejs/plugin-react')());
});
const test = baseTest.extend({
_workerPage: [async ({ browser }, use) => {
@ -45,4 +48,4 @@ const test = baseTest.extend({
},
});
module.exports = { test, expect };
module.exports = { test, expect, devices };

Просмотреть файл

@ -14,7 +14,7 @@
"license": "Apache-2.0",
"exports": {
"./register": "./register.mjs",
"./test": "./test.js"
".": "./index.js"
},
"dependencies": {
"@vitejs/plugin-react": "^1.0.7",

Просмотреть файл

@ -4,7 +4,5 @@
!LICENSE
!register.d.ts
!register.mjs
!test.d.ts
!test.js
!vitePlugin.d.ts
!vitePlugin.js
!index.d.ts
!index.js

Просмотреть файл

@ -17,11 +17,17 @@
import type {
TestType,
PlaywrightTestArgs,
PlaywrightTestConfig as BasePlaywrightTestConfig,
PlaywrightTestOptions,
PlaywrightWorkerArgs,
PlaywrightWorkerOptions,
Locator,
} from '@playwright/test';
import type { InlineConfig } from 'vite';
export type PlaywrightTestConfig = Omit<BasePlaywrightTestConfig, 'use'> & {
use: BasePlaywrightTestConfig['use'] & { vitePort?: number, viteConfig?: InlineConfig }
};
interface ComponentFixtures {
mount(component: any, options?: {
@ -35,4 +41,4 @@ export const test: TestType<
PlaywrightTestArgs & PlaywrightTestOptions & ComponentFixtures,
PlaywrightWorkerArgs & PlaywrightWorkerOptions>;
export { expect } from '@playwright/test';
export { expect, devices } from '@playwright/test';

Просмотреть файл

@ -14,13 +14,16 @@
* limitations under the License.
*/
const { test: baseTest, expect, _addRunnerPlugin } = require('@playwright/test');
const { test: baseTest, expect, devices, _addRunnerPlugin } = require('@playwright/test');
const { mount } = require('@playwright/test/lib/mount');
const { createPlugin } = require('@playwright/test/lib/plugins/vitePlugin');
_addRunnerPlugin(createPlugin(
'@playwright/experimental-ct-svelte/register',
() => require('@sveltejs/vite-plugin-svelte').svelte()));
_addRunnerPlugin(() => {
// Only fetch upon request to avoid resolution in workers.
const { createPlugin } = require('@playwright/test/lib/plugins/vitePlugin');
return createPlugin(
'@playwright/experimental-ct-svelte/register',
() => require('@sveltejs/vite-plugin-svelte').svelte());
});
const test = baseTest.extend({
_workerPage: [async ({ browser }, use) => {
@ -45,4 +48,4 @@ const test = baseTest.extend({
},
});
module.exports = { test, expect };
module.exports = { test, expect, devices };

Просмотреть файл

@ -14,7 +14,7 @@
"license": "Apache-2.0",
"exports": {
"./register": "./register.mjs",
"./test": "./test.js"
".": "./index.js"
},
"dependencies": {
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.30",

Просмотреть файл

@ -4,7 +4,5 @@
!LICENSE
!register.d.ts
!register.mjs
!test.d.ts
!test.js
!vitePlugin.d.ts
!vitePlugin.js
!index.d.ts
!index.js

Просмотреть файл

@ -17,11 +17,17 @@
import type {
TestType,
PlaywrightTestArgs,
PlaywrightTestConfig as BasePlaywrightTestConfig,
PlaywrightTestOptions,
PlaywrightWorkerArgs,
PlaywrightWorkerOptions,
Locator,
} from '@playwright/test';
import type { InlineConfig } from 'vite';
export type PlaywrightTestConfig = Omit<BasePlaywrightTestConfig, 'use'> & {
use: BasePlaywrightTestConfig['use'] & { vitePort?: number, viteConfig?: InlineConfig }
};
interface ComponentFixtures {
mount(component: JSX.Element): Promise<Locator>;
@ -36,4 +42,4 @@ export const test: TestType<
PlaywrightTestArgs & PlaywrightTestOptions & ComponentFixtures,
PlaywrightWorkerArgs & PlaywrightWorkerOptions>;
export { expect } from '@playwright/test';
export { expect, devices } from '@playwright/test';

Просмотреть файл

@ -14,13 +14,16 @@
* limitations under the License.
*/
const { test: baseTest, expect, _addRunnerPlugin } = require('@playwright/test');
const { test: baseTest, expect, devices, _addRunnerPlugin } = require('@playwright/test');
const { mount } = require('@playwright/test/lib/mount');
const { createPlugin } = require('@playwright/test/lib/plugins/vitePlugin');
_addRunnerPlugin(createPlugin(
'@playwright/experimental-ct-vue/register',
() => require('@vitejs/plugin-vue')()));
_addRunnerPlugin(() => {
// Only fetch upon request to avoid resolution in workers.
const { createPlugin } = require('@playwright/test/lib/plugins/vitePlugin');
return createPlugin(
'@playwright/experimental-ct-vue/register',
() => require('@vitejs/plugin-vue')());
});
const test = baseTest.extend({
_workerPage: [async ({ browser }, use) => {
@ -45,4 +48,4 @@ const test = baseTest.extend({
},
});
module.exports = { test, expect };
module.exports = { test, expect, devices };

Просмотреть файл

@ -14,7 +14,7 @@
"license": "Apache-2.0",
"exports": {
"./register": "./register.mjs",
"./test": "./test.js"
".": "./index.js"
},
"dependencies": {
"@vitejs/plugin-vue": "^2.3.1",

Просмотреть файл

@ -4,4 +4,3 @@ matchers/
reporters/
third_party/
plugins/
plugins/webServerPlugin.ts

Просмотреть файл

@ -33,8 +33,10 @@ export const setRunnerToAddPluginsTo = (runner: Runner) => {
runnerInstanceToAddPluginsTo = runner;
};
export const addRunnerPlugin = (plugin: TestRunnerPlugin) => {
export const addRunnerPlugin = (plugin: TestRunnerPlugin | (() => TestRunnerPlugin)) => {
// Only present in runner, absent in worker.
if (runnerInstanceToAddPluginsTo)
if (runnerInstanceToAddPluginsTo) {
plugin = typeof plugin === 'function' ? plugin() : plugin;
runnerInstanceToAddPluginsTo.addPlugin(plugin);
}
};

Просмотреть файл

@ -34,9 +34,9 @@ export function createPlugin(
name: 'playwright-vite-plugin',
setup: async (config: FullConfig, configDirectory: string, suite: Suite) => {
// TODO: declare and pick these from the config.
const viteConfig: InlineConfig = {};
const port = 3100;
const use = config.projects[0].use as any;
const viteConfig: InlineConfig = use.viteConfig || {};
const port = use.vitePort || 3100;
configDir = configDirectory;

Просмотреть файл

@ -14,19 +14,16 @@
* limitations under the License.
*/
import type { PlaywrightTestConfig } from '@playwright/test';
import { devices } from '@playwright/test';
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: process.env.CI ? [
['html', { open: 'never' }],
] : [
['html', { open: 'on-failure' }]
],
reporter: 'html',
use: {
vitePort: 3102,
trace: 'on-first-retry',
},
projects: [

Просмотреть файл

@ -15,7 +15,7 @@
*/
import React from 'react';
import { expect, test } from '@playwright/experimental-ct-react/test';
import { expect, test } from '@playwright/experimental-ct-react';
import { Expandable } from './expandable';
test.use({ viewport: { width: 500, height: 500 } });

Просмотреть файл

@ -15,7 +15,7 @@
*/
import React from 'react';
import { expect, test } from '@playwright/experimental-ct-react/test';
import { expect, test } from '@playwright/experimental-ct-react';
import { Source } from './source';
test.use({ viewport: { width: 500, height: 500 } });

Просмотреть файл

@ -15,7 +15,7 @@
*/
import React from 'react';
import { expect, test } from '@playwright/experimental-ct-react/test';
import { expect, test } from '@playwright/experimental-ct-react';
import { SplitView } from './splitView';
test.use({ viewport: { width: 500, height: 500 } });

Просмотреть файл

@ -14,7 +14,7 @@
* limitations under the License.
*/
import { PlaywrightTestConfig, devices } from '@playwright/test';
import { type PlaywrightTestConfig, devices } from '@playwright/experimental-ct-react';
const config: PlaywrightTestConfig = {
testDir: 'src',

Просмотреть файл

@ -1,4 +1,4 @@
import { test, expect } from '@playwright/experimental-ct-react/test';
import { test, expect } from '@playwright/experimental-ct-react';
import App from './App';
test.use({ viewport: { width: 500, height: 500 } });

Просмотреть файл

@ -14,7 +14,7 @@
* limitations under the License.
*/
import { PlaywrightTestConfig, devices } from '@playwright/test';
import { type PlaywrightTestConfig, devices } from '@playwright/experimental-ct-react';
const config: PlaywrightTestConfig = {
testDir: 'src',

Просмотреть файл

@ -1,4 +1,4 @@
import { test, expect } from '@playwright/experimental-ct-react/test';
import { test, expect } from '@playwright/experimental-ct-react';
import App from './App';
test.use({ viewport: { width: 500, height: 500 } });

Просмотреть файл

@ -14,7 +14,7 @@
* limitations under the License.
*/
import type { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/experimental-ct-svelte';
import { devices } from '@playwright/test';
const config: PlaywrightTestConfig = {

Просмотреть файл

@ -14,7 +14,7 @@
* limitations under the License.
*/
import { test, expect } from '@playwright/experimental-ct-svelte/test';
import { test, expect } from '@playwright/experimental-ct-svelte';
import Counter from './Counter.svelte';
test.use({ viewport: { width: 500, height: 500 } });

Просмотреть файл

@ -14,7 +14,7 @@
* limitations under the License.
*/
import type { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/experimental-ct-svelte';
import { devices } from '@playwright/test';
const config: PlaywrightTestConfig = {

Просмотреть файл

@ -14,7 +14,7 @@
* limitations under the License.
*/
import { test, expect } from '@playwright/experimental-ct-svelte/test';
import { test, expect } from '@playwright/experimental-ct-svelte';
import Counter from './Counter.svelte';
test.use({ viewport: { width: 500, height: 500 } });

Просмотреть файл

@ -14,7 +14,7 @@
* limitations under the License.
*/
import type { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/experimental-ct-svelte';
import { devices } from '@playwright/test';
const config: PlaywrightTestConfig = {

Просмотреть файл

@ -14,7 +14,7 @@
* limitations under the License.
*/
import { test, expect } from '@playwright/experimental-ct-svelte/test';
import { test, expect } from '@playwright/experimental-ct-svelte';
import App from './App.svelte';
test.use({ viewport: { width: 500, height: 500 } });

Просмотреть файл

@ -14,7 +14,7 @@
* limitations under the License.
*/
import { PlaywrightTestConfig, devices } from '@playwright/test';
import { type PlaywrightTestConfig, devices } from '@playwright/experimental-ct-vue';
const config: PlaywrightTestConfig = {
testDir: 'src',

Просмотреть файл

@ -1,4 +1,4 @@
import { test, expect } from '@playwright/experimental-ct-vue/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'

Просмотреть файл

@ -1,4 +1,4 @@
import { test, expect } from '@playwright/experimental-ct-vue/test'
import { test, expect } from '@playwright/experimental-ct-vue'
import Button from './components/Button.vue'
import DefaultSlot from './components/DefaultSlot.vue'

Просмотреть файл

@ -14,7 +14,7 @@
* limitations under the License.
*/
import { PlaywrightTestConfig, devices } from '@playwright/test';
import { type PlaywrightTestConfig, devices } from '@playwright/experimental-ct-vue';
const config: PlaywrightTestConfig = {
testDir: 'src',

Просмотреть файл

@ -1,4 +1,4 @@
import { test, expect } from '@playwright/experimental-ct-vue/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'

Просмотреть файл

@ -1,4 +1,4 @@
import { test, expect } from '@playwright/experimental-ct-vue/test'
import { test, expect } from '@playwright/experimental-ct-vue'
import Button from './components/Button.vue'
import DefaultSlot from './components/DefaultSlot.vue'