From a713300c5b4b1b85ed7ac0355828f148835696d3 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Fri, 2 May 2025 13:50:03 +0200 Subject: [PATCH] test: use TestOptions type in config (#326) --- .gitignore | 1 + playwright.config.ts | 8 ++++---- tests/device.spec.ts | 2 +- tests/fixtures.ts | 7 +++++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index fcfd67d..1089cef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ lib/ node_modules/ test-results/ +playwright-report/ .vscode/mcp.json .idea diff --git a/playwright.config.ts b/playwright.config.ts index ddb3ce7..2a99955 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -16,20 +16,20 @@ import { defineConfig } from '@playwright/test'; -import type { Project } from '@playwright/test'; +import type { TestOptions } from './tests/fixtures.js'; -export default defineConfig({ +export default defineConfig({ testDir: './tests', fullyParallel: true, forbidOnly: !!process.env.CI, retries: process.env.CI ? 2 : 0, workers: process.env.CI ? 1 : undefined, - reporter: 'list', + reporter: process.env.CI ? 'list' : [['list'], ['html']], projects: [ { name: 'chrome' }, { name: 'msedge', use: { mcpBrowser: 'msedge' } }, { name: 'chromium', use: { mcpBrowser: 'chromium' } }, { name: 'firefox', use: { mcpBrowser: 'firefox' } }, { name: 'webkit', use: { mcpBrowser: 'webkit' } }, - ].filter(Boolean) as Project[], + ], }); diff --git a/tests/device.spec.ts b/tests/device.spec.ts index 8b3c708..3fe2933 100644 --- a/tests/device.spec.ts +++ b/tests/device.spec.ts @@ -16,7 +16,7 @@ import { test, expect } from './fixtures.js'; -test('browser_take_screenshot (viewport)', async ({ startClient, server }) => { +test('--device should work', async ({ startClient, server }) => { const client = await startClient({ args: ['--device', 'iPhone 15'], }); diff --git a/tests/fixtures.ts b/tests/fixtures.ts index dcc1481..c38b4a8 100644 --- a/tests/fixtures.ts +++ b/tests/fixtures.ts @@ -27,6 +27,10 @@ import { TestServer } from './testserver/index.ts'; import type { Config } from '../config'; +export type TestOptions = { + mcpBrowser: string | undefined; +}; + type TestFixtures = { client: Client; visionClient: Client; @@ -36,14 +40,13 @@ type TestFixtures = { server: TestServer; httpsServer: TestServer; mcpHeadless: boolean; - mcpBrowser: string | undefined; }; type WorkerFixtures = { _workerServers: { server: TestServer, httpsServer: TestServer }; }; -export const test = baseTest.extend({ +export const test = baseTest.extend({ client: async ({ startClient }, use) => { await use(await startClient());