From 579bda97aac0c8899145bc2e007e332201534cad Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Mon, 23 Dec 2024 17:34:01 +0900 Subject: [PATCH] fix(browser): fix provider options types (#7115) --- packages/browser/providers/playwright.d.ts | 3 ++- packages/browser/providers/webdriverio.d.ts | 3 ++- test/dts-playwright/src/basic.test.ts | 1 - test/dts-playwright/tsconfig.json | 3 ++- test/dts-playwright/vite.config.ts | 26 +++++++++++++++++++++ 5 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 test/dts-playwright/vite.config.ts diff --git a/packages/browser/providers/playwright.d.ts b/packages/browser/providers/playwright.d.ts index 53f198cdde86..bf0f45edabb2 100644 --- a/packages/browser/providers/playwright.d.ts +++ b/packages/browser/providers/playwright.d.ts @@ -9,9 +9,10 @@ import type { } from 'playwright' import { Protocol } from 'playwright-core/types/protocol' import '../matchers.js' +import type {} from "vitest/node" declare module 'vitest/node' { - interface BrowserProviderOptions { + export interface BrowserProviderOptions { launch?: LaunchOptions context?: Omit< BrowserContextOptions, diff --git a/packages/browser/providers/webdriverio.d.ts b/packages/browser/providers/webdriverio.d.ts index 1c4a2b75bfdb..46776a9f08df 100644 --- a/packages/browser/providers/webdriverio.d.ts +++ b/packages/browser/providers/webdriverio.d.ts @@ -1,8 +1,9 @@ import type { RemoteOptions, ClickOptions, DragAndDropOptions } from 'webdriverio' import '../matchers.js' +import type {} from "vitest/node" declare module 'vitest/node' { - interface BrowserProviderOptions extends Partial {} + export interface BrowserProviderOptions extends Partial {} export interface UserEventClickOptions extends ClickOptions {} diff --git a/test/dts-playwright/src/basic.test.ts b/test/dts-playwright/src/basic.test.ts index f117475ddc0a..4aec7d2dbe94 100644 --- a/test/dts-playwright/src/basic.test.ts +++ b/test/dts-playwright/src/basic.test.ts @@ -1,4 +1,3 @@ -/// import { page, userEvent } from '@vitest/browser/context' import { test } from 'vitest' diff --git a/test/dts-playwright/tsconfig.json b/test/dts-playwright/tsconfig.json index 03578c57e6d3..87c7ac1e7810 100644 --- a/test/dts-playwright/tsconfig.json +++ b/test/dts-playwright/tsconfig.json @@ -3,8 +3,9 @@ "target": "ESNext", "module": "ESNext", "moduleResolution": "Bundler", + "types": ["@vitest/browser/providers/playwright"], "strict": true, "noEmit": true }, - "include": ["src"] + "include": ["src", "*.ts"] } diff --git a/test/dts-playwright/vite.config.ts b/test/dts-playwright/vite.config.ts new file mode 100644 index 000000000000..250f59b25fd2 --- /dev/null +++ b/test/dts-playwright/vite.config.ts @@ -0,0 +1,26 @@ +import { defineConfig } from 'vitest/config' + +export default defineConfig({ + test: { + browser: { + provider: 'playwright', + providerOptions: { + launch: { + timeout: 1234, + // @ts-expect-error test type error + slowMo: 'wrong', + }, + }, + instances: [ + { + browser: 'chromium', + launch: { + timeout: 1234, + // @ts-expect-error test type error + slowMo: 'wrong', + }, + }, + ], + }, + }, +})