From 66bee836f5d191d749a2d292cc2883117f48f775 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Sat, 21 Jun 2025 19:48:02 +0200 Subject: [PATCH] fix!: remove deprecated types (#8203) --- packages/runner/src/map.ts | 6 +++--- packages/runner/src/types.ts | 6 ------ packages/runner/src/types/tasks.ts | 21 --------------------- packages/vitest/src/api/setup.ts | 3 --- packages/vitest/src/api/types.ts | 3 --- packages/vitest/src/node/globalSetup.ts | 3 --- packages/vitest/src/node/reporters/junit.ts | 5 ----- packages/vitest/src/node/types/browser.ts | 2 -- packages/vitest/src/public/index.ts | 3 --- packages/vitest/src/public/node.ts | 1 - packages/vitest/src/types/rpc.ts | 6 ------ test/reporters/tests/junit.test.ts | 15 --------------- test/reporters/tests/reporters.spec.ts | 2 +- test/workspaces/globalTest.ts | 4 ++-- test/workspaces/space_3/localSetup.ts | 4 ++-- 15 files changed, 8 insertions(+), 76 deletions(-) diff --git a/packages/runner/src/map.ts b/packages/runner/src/map.ts index f2d33e633..4f375cb63 100644 --- a/packages/runner/src/map.ts +++ b/packages/runner/src/map.ts @@ -1,17 +1,17 @@ import type { Awaitable } from '@vitest/utils' import type { FixtureItem } from './fixture' -import type { Custom, Suite, SuiteHooks, Test, TestContext } from './types/tasks' +import type { Suite, SuiteHooks, Test, TestContext } from './types/tasks' // use WeakMap here to make the Test and Suite object serializable const fnMap = new WeakMap() const testFixtureMap = new WeakMap() const hooksMap = new WeakMap() -export function setFn(key: Test | Custom, fn: () => Awaitable): void { +export function setFn(key: Test, fn: () => Awaitable): void { fnMap.set(key, fn) } -export function getFn(key: Task): () => Awaitable { +export function getFn(key: Task): () => Awaitable { return fnMap.get(key as any) } diff --git a/packages/runner/src/types.ts b/packages/runner/src/types.ts index b116a8a4b..1b86aa85f 100644 --- a/packages/runner/src/types.ts +++ b/packages/runner/src/types.ts @@ -11,11 +11,6 @@ export type { AfterEachListener, BeforeAllListener, BeforeEachListener, - Custom, - /** @deprecated use `TestAPI` instead */ - CustomAPI, - DoneCallback, - ExtendedContext, File, Fixture, FixtureFn, @@ -38,7 +33,6 @@ export type { SuiteHooks, Task, TaskBase, - TaskContext, TaskCustomOptions, TaskEventPack, TaskHook, diff --git a/packages/runner/src/types/tasks.ts b/packages/runner/src/types/tasks.ts index d06966102..616c49d44 100644 --- a/packages/runner/src/types/tasks.ts +++ b/packages/runner/src/types/tasks.ts @@ -297,17 +297,8 @@ export interface TestAnnotation { attachment?: TestAttachment } -/** - * @deprecated Use `Test` instead. `type: 'custom'` is not used since 2.2 - */ -export type Custom = Test - export type Task = Test | Suite | File -/** - * @deprecated Vitest doesn't provide `done()` anymore - */ -export type DoneCallback = (error?: any) => void export type TestFunction = ( context: TestContext & ExtraContext ) => Awaitable | void @@ -517,9 +508,6 @@ export type TestAPI = ChainableTestAPI & ) => void } -/** @deprecated use `TestAPI` instead */ -export type { TestAPI as CustomAPI } - export interface FixtureOptions { /** * Whether to automatically set up current fixture, even though it's not being used in tests. @@ -743,15 +731,6 @@ export interface TestContext { } } -/** - * Context that's always available in the test function. - * @deprecated use `TestContext` instead - */ -export interface TaskContext extends TestContext {} - -/** @deprecated use `TestContext` instead */ -export type ExtendedContext = TaskContext & TestContext - export type OnTestFailedHandler = (context: TestContext) => Awaitable export type OnTestFinishedHandler = (context: TestContext) => Awaitable diff --git a/packages/vitest/src/api/setup.ts b/packages/vitest/src/api/setup.ts index d0d849952..e80e552cc 100644 --- a/packages/vitest/src/api/setup.ts +++ b/packages/vitest/src/api/setup.ts @@ -88,9 +88,6 @@ export function setup(ctx: Vitest, _server?: ViteDevServer): void { getConfig() { return ctx.getRootProject().serializedConfig }, - getResolvedProjectNames(): string[] { - return ctx.projects.map(p => p.name) - }, getResolvedProjectLabels(): { name: string; color?: LabelColor }[] { return ctx.projects.map(p => ({ name: p.name, color: p.color })) }, diff --git a/packages/vitest/src/api/types.ts b/packages/vitest/src/api/types.ts index b70f32d95..b838c0831 100644 --- a/packages/vitest/src/api/types.ts +++ b/packages/vitest/src/api/types.ts @@ -32,9 +32,6 @@ export interface WebSocketHandlers { getTestFiles: () => Promise getPaths: () => string[] getConfig: () => SerializedConfig - // TODO: Remove in v4 - /** @deprecated -- Use `getResolvedProjectLabels` instead */ - getResolvedProjectNames: () => string[] getResolvedProjectLabels: () => { name: string; color?: LabelColor }[] getModuleGraph: ( projectName: string, diff --git a/packages/vitest/src/node/globalSetup.ts b/packages/vitest/src/node/globalSetup.ts index 435dbbe19..51e5174f3 100644 --- a/packages/vitest/src/node/globalSetup.ts +++ b/packages/vitest/src/node/globalSetup.ts @@ -2,9 +2,6 @@ import type { ViteNodeRunner } from 'vite-node/client' import type { TestProject } from './project' import { toArray } from '@vitest/utils' -/** @deprecated use `TestProject` instead */ -export type GlobalSetupContext = TestProject - export interface GlobalSetupFile { file: string setup?: (context: TestProject) => Promise | void diff --git a/packages/vitest/src/node/reporters/junit.ts b/packages/vitest/src/node/reporters/junit.ts index 211693234..c2011ce21 100644 --- a/packages/vitest/src/node/reporters/junit.ts +++ b/packages/vitest/src/node/reporters/junit.ts @@ -18,8 +18,6 @@ interface ClassnameTemplateVariables { export interface JUnitOptions { outputFile?: string - /** @deprecated Use `classnameTemplate` instead. */ - classname?: string /** * Template for the classname attribute. Can be either a string or a function. The string can contain placeholders {filename} and {filepath}. @@ -221,9 +219,6 @@ export class JUnitReporter implements Reporter { .replace(/\{filename\}/g, templateVars.filename) .replace(/\{filepath\}/g, templateVars.filepath) } - else if (typeof this.options.classname === 'string') { - classname = this.options.classname - } await this.writeElement( 'testcase', diff --git a/packages/vitest/src/node/types/browser.ts b/packages/vitest/src/node/types/browser.ts index 6a756083d..0d427c1a9 100644 --- a/packages/vitest/src/node/types/browser.ts +++ b/packages/vitest/src/node/types/browser.ts @@ -242,8 +242,6 @@ export interface BrowserCommandContext { testPath: string | undefined provider: BrowserProvider project: TestProject - /** @deprecated use `sessionId` instead */ - contextId: string sessionId: string } diff --git a/packages/vitest/src/public/index.ts b/packages/vitest/src/public/index.ts index dc5376386..5f6c10699 100644 --- a/packages/vitest/src/public/index.ts +++ b/packages/vitest/src/public/index.ts @@ -83,14 +83,12 @@ export { test, } from '@vitest/runner' export type { - ExtendedContext, HookCleanupCallback, HookListener, ImportDuration, OnTestFailedHandler, OnTestFinishedHandler, RunMode, - Custom as RunnerCustomCase, Task as RunnerTask, TaskBase as RunnerTaskBase, TaskEventPack as RunnerTaskEventPack, @@ -102,7 +100,6 @@ export type { SuiteAPI, SuiteCollector, SuiteFactory, - TaskContext, TaskCustomOptions, TaskMeta, TaskState, diff --git a/packages/vitest/src/public/node.ts b/packages/vitest/src/public/node.ts index b654ebf4f..a572bfb6d 100644 --- a/packages/vitest/src/public/node.ts +++ b/packages/vitest/src/public/node.ts @@ -16,7 +16,6 @@ export type { } from '../node/core' export { createVitest } from '../node/create' export { GitNotFoundError, FilesNotFoundError as TestsNotFoundError } from '../node/errors' -export type { GlobalSetupContext } from '../node/globalSetup' export { VitestPackageInstaller } from '../node/packageInstaller' export { VitestPlugin } from '../node/plugins' export { resolveConfig } from '../node/plugins/publicConfig' diff --git a/packages/vitest/src/types/rpc.ts b/packages/vitest/src/types/rpc.ts index a0f337502..f6fd773e8 100644 --- a/packages/vitest/src/types/rpc.ts +++ b/packages/vitest/src/types/rpc.ts @@ -20,12 +20,6 @@ export interface RuntimeRPC { ) => Promise<{ external?: boolean | 'absolute' | 'relative' id: string - /** @deprecated */ - meta?: Record | null - /** @deprecated */ - moduleSideEffects?: boolean | 'no-treeshake' | null - /** @deprecated */ - syntheticNamedExports?: boolean | string | null } | null> onUserConsoleLog: (log: UserConsoleLog) => void diff --git a/test/reporters/tests/junit.test.ts b/test/reporters/tests/junit.test.ts index ff13d9ca4..861ca9cb4 100644 --- a/test/reporters/tests/junit.test.ts +++ b/test/reporters/tests/junit.test.ts @@ -100,21 +100,6 @@ test('write testsuite name relative to root config', async () => { expect(xml).toContain('') }) -test('options.classname changes classname property', async () => { - const { stdout } = await runVitest({ - reporters: [['junit', { classname: 'some-custom-classname' }]], - root: './fixtures/default', - include: ['a.test.ts'], - }) - - const xml = stabilizeReport(stdout) - - // All classname attributes should have the custom value - expect(xml.match(/ { const { stdout } = await runVitest({ reporters: [['junit', { suiteName: 'some-custom-suiteName' }]], diff --git a/test/reporters/tests/reporters.spec.ts b/test/reporters/tests/reporters.spec.ts index b52ed51ce..b597d7727 100644 --- a/test/reporters/tests/reporters.spec.ts +++ b/test/reporters/tests/reporters.spec.ts @@ -76,7 +76,7 @@ test('JUnit reporter without classname', async () => { test('JUnit reporter with custom string classname', async () => { // Arrange - const reporter = new JUnitReporter({ classname: 'my-custom-classname' }) + const reporter = new JUnitReporter({ classnameTemplate: 'my-custom-classname' }) const context = getContext() // Act diff --git a/test/workspaces/globalTest.ts b/test/workspaces/globalTest.ts index 20bbda8d7..992ff4f90 100644 --- a/test/workspaces/globalTest.ts +++ b/test/workspaces/globalTest.ts @@ -1,4 +1,4 @@ -import type { GlobalSetupContext } from 'vitest/node' +import type { TestProject } from 'vitest/node' import assert from 'node:assert/strict' import { readFile } from 'node:fs/promises' @@ -14,7 +14,7 @@ declare module 'vitest' { } } -export function setup({ provide }: GlobalSetupContext) { +export function setup({ provide }: TestProject) { provide('globalSetup', true) provide('globalSetupOverridden', false) try { diff --git a/test/workspaces/space_3/localSetup.ts b/test/workspaces/space_3/localSetup.ts index 7a449c4c2..eeb0213c3 100644 --- a/test/workspaces/space_3/localSetup.ts +++ b/test/workspaces/space_3/localSetup.ts @@ -1,5 +1,5 @@ -import type { GlobalSetupContext } from 'vitest/node' +import type { TestProject } from 'vitest/node' -export function setup({ provide }: GlobalSetupContext) { +export function setup({ provide }: TestProject) { provide('globalSetupOverridden', true) } -- 2.51.2