diff --git a/packages/vitest/src/config.ts b/packages/vitest/src/config.ts index 541d610a56ab..84dd44482d89 100644 --- a/packages/vitest/src/config.ts +++ b/packages/vitest/src/config.ts @@ -6,7 +6,6 @@ export interface UserConfig extends ViteUserConfig { } export interface UserWorkspaceConfig extends ViteUserConfig { - extends?: string test?: ProjectConfig } @@ -29,6 +28,6 @@ export function defineProject(config: UserProjectConfigExport) { return config } -export function defineWorkspace(config: (string | UserProjectConfigExport)[]) { +export function defineWorkspace(config: (string | (UserProjectConfigExport & { extends?: string }))[]) { return config } diff --git a/packages/vitest/src/node/pools/threads.ts b/packages/vitest/src/node/pools/threads.ts index 4961b15c3070..3335ed477788 100644 --- a/packages/vitest/src/node/pools/threads.ts +++ b/packages/vitest/src/node/pools/threads.ts @@ -9,7 +9,7 @@ import { distDir } from '../../paths' import type { ContextTestEnvironment, ResolvedConfig, RuntimeRPC, Vitest, WorkerContext } from '../../types' import type { PoolProcessOptions, ProcessPool, RunWithFiles } from '../pool' import { envsOrder, groupFilesByEnv } from '../../utils/test-helpers' -import { groupBy } from '../../utils/base' +import { AggregateError, groupBy } from '../../utils/base' import type { WorkspaceProject } from '../workspace' import { createMethodsRPC } from './rpc' diff --git a/packages/vitest/src/node/workspace.ts b/packages/vitest/src/node/workspace.ts index 895d4e79f280..2c306d220db1 100644 --- a/packages/vitest/src/node/workspace.ts +++ b/packages/vitest/src/node/workspace.ts @@ -19,7 +19,7 @@ interface InitializeOptions { runner?: ViteNodeRunner } -export async function initializeProject(workspacePath: string | number, ctx: Vitest, options: UserWorkspaceConfig = {}) { +export async function initializeProject(workspacePath: string | number, ctx: Vitest, options: (UserWorkspaceConfig & { extends?: string }) = {}) { const project = new WorkspaceProject(workspacePath, ctx) const configFile = options.extends diff --git a/packages/vitest/src/runtime/entry.ts b/packages/vitest/src/runtime/entry.ts index e16f75285214..471f02fd6497 100644 --- a/packages/vitest/src/runtime/entry.ts +++ b/packages/vitest/src/runtime/entry.ts @@ -1,3 +1,4 @@ +import { performance } from 'node:perf_hooks' import type { VitestRunner, VitestRunnerConstructor } from '@vitest/runner' import { startTests } from '@vitest/runner' import { resolve } from 'pathe' diff --git a/packages/vitest/src/runtime/runners/benchmark.ts b/packages/vitest/src/runtime/runners/benchmark.ts index d64f556b2014..81a8d013253d 100644 --- a/packages/vitest/src/runtime/runners/benchmark.ts +++ b/packages/vitest/src/runtime/runners/benchmark.ts @@ -1,3 +1,4 @@ +import { performance } from 'node:perf_hooks' import type { Suite, Task, VitestRunner, VitestRunnerImportSource } from '@vitest/runner' import { updateTask as updateRunnerTask } from '@vitest/runner' import { createDefer, getSafeTimers } from '@vitest/utils' diff --git a/packages/vitest/src/runtime/worker.ts b/packages/vitest/src/runtime/worker.ts index 586d9390067c..105d470f08f3 100644 --- a/packages/vitest/src/runtime/worker.ts +++ b/packages/vitest/src/runtime/worker.ts @@ -1,3 +1,4 @@ +import { performance } from 'node:perf_hooks' import { createBirpc } from 'birpc' import { workerId as poolId } from 'tinypool' import type { RuntimeRPC, WorkerContext } from '../types' diff --git a/packages/vitest/src/utils/base.ts b/packages/vitest/src/utils/base.ts index 96155f4149ac..86e3713143f1 100644 --- a/packages/vitest/src/utils/base.ts +++ b/packages/vitest/src/utils/base.ts @@ -133,3 +133,13 @@ export function getEnvironmentTransformMode(config: ResolvedConfig, environment: return undefined return (environment === 'happy-dom' || environment === 'jsdom') ? 'web' : 'ssr' } + +// AggregateError is supported in Node.js 15.0.0+ +class AggregateErrorPonyfill extends Error { + errors: unknown[] + constructor(errors: Iterable, message = '') { + super(message) + this.errors = [...errors] + } +} +export { AggregateErrorPonyfill as AggregateError } diff --git a/packages/vitest/src/utils/index.ts b/packages/vitest/src/utils/index.ts index 4d91d3f9f1d3..7cf3ea9540bf 100644 --- a/packages/vitest/src/utils/index.ts +++ b/packages/vitest/src/utils/index.ts @@ -52,16 +52,6 @@ export function removeUndefinedValues>(obj: T): T return obj } -// AggregateError is supported in Node.js 15.0.0+ -class AggregateErrorPonyfill extends Error { - errors: unknown[] - constructor(errors: Iterable, message = '') { - super(message) - this.errors = [...errors] - } -} -export { AggregateErrorPonyfill as AggregateError } - export function objectAttr(source: any, path: string, defaultValue = undefined) { // a[3].b -> a.3.b const paths = path.replace(/\[(\d+)\]/g, '.$1').split('.')