diff --git a/package.json b/package.json
index d3563d819f40..6d889d8f317e 100644
--- a/package.json
+++ b/package.json
@@ -67,6 +67,7 @@
},
"pnpm": {
"overrides": {
+ "acorn": "8.11.3",
"mlly": "^1.7.1",
"rollup": "$rollup",
"vite": "$vite",
diff --git a/packages/vitest/LICENSE.md b/packages/vitest/LICENSE.md
index c98f8251bc14..e012ba88698a 100644
--- a/packages/vitest/LICENSE.md
+++ b/packages/vitest/LICENSE.md
@@ -438,6 +438,27 @@ License: MIT
By: Mathias Bynens
Repository: https://github.com/mathiasbynens/emoji-regex.git
+> Copyright Mathias Bynens
+>
+> Permission is hereby granted, free of charge, to any person obtaining
+> a copy of this software and associated documentation files (the
+> "Software"), to deal in the Software without restriction, including
+> without limitation the rights to use, copy, modify, merge, publish,
+> distribute, sublicense, and/or sell copies of the Software, and to
+> permit persons to whom the Software is furnished to do so, subject to
+> the following conditions:
+>
+> The above copyright notice and this permission notice shall be
+> included in all copies or substantial portions of the Software.
+>
+> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+> NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+> LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+> OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+> WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
---------------------------------------
## expect-type
diff --git a/packages/vitest/rollup.config.js b/packages/vitest/rollup.config.js
index 76146f668528..afe9ff7b6e7e 100644
--- a/packages/vitest/rollup.config.js
+++ b/packages/vitest/rollup.config.js
@@ -1,7 +1,7 @@
import fs from 'node:fs'
import { builtinModules, createRequire } from 'node:module'
import { fileURLToPath } from 'node:url'
-import { dirname, join, normalize, relative, resolve } from 'pathe'
+import { dirname, join, normalize, resolve } from 'pathe'
import esbuild from 'rollup-plugin-esbuild'
import dts from 'rollup-plugin-dts'
import nodeResolve from '@rollup/plugin-node-resolve'
@@ -17,13 +17,13 @@ const pkg = require('./package.json')
const entries = {
'path': 'src/paths.ts',
- 'index': 'src/index.ts',
+ 'index': 'src/public/index.ts',
'cli': 'src/node/cli.ts',
- 'node': 'src/node.ts',
+ 'node': 'src/public/node.ts',
'suite': 'src/suite.ts',
'browser': 'src/browser.ts',
'runners': 'src/runners.ts',
- 'environments': 'src/environments.ts',
+ 'environments': 'src/public/environments.ts',
'spy': 'src/integrations/spy.ts',
'coverage': 'src/coverage.ts',
'utils': 'src/public/utils.ts',
@@ -45,9 +45,9 @@ const entries = {
}
const dtsEntries = {
- index: 'src/index.ts',
- node: 'src/node.ts',
- environments: 'src/environments.ts',
+ index: 'src/public/index.ts',
+ node: 'src/public/node.ts',
+ environments: 'src/public/environments.ts',
browser: 'src/browser.ts',
runners: 'src/runners.ts',
suite: 'src/suite.ts',
@@ -107,35 +107,7 @@ export default ({ watch }) =>
output: {
dir: 'dist',
format: 'esm',
- chunkFileNames: (chunkInfo) => {
- let id
- = chunkInfo.facadeModuleId
- || Object.keys(chunkInfo.moduleIds).find(
- i =>
- !i.includes('node_modules')
- && (i.includes('src/') || i.includes('src\\')),
- )
- if (id) {
- id = normalize(id)
- const parts = Array.from(
- new Set(
- relative(process.cwd(), id)
- .split(/\//g)
- .map(i => i.replace(/\..*$/, ''))
- .filter(
- i =>
- !['src', 'index', 'dist', 'node_modules'].some(j =>
- i.includes(j),
- ) && i.match(/^[\w-]+$/),
- ),
- ),
- )
- if (parts.length) {
- return `chunks/${parts.slice(-2).join('-')}.[hash].js`
- }
- }
- return 'vendor/[name].[hash].js'
- },
+ chunkFileNames: 'chunks/[name].[hash].js',
},
external,
plugins: [...plugins, !watch && licensePlugin()],
@@ -163,6 +135,7 @@ export default ({ watch }) =>
entryFileNames: chunk =>
`${normalize(chunk.name).replace('src/', '')}.d.ts`,
format: 'esm',
+ chunkFileNames: 'chunks/[name].[hash].d.ts',
},
external,
plugins: [dts({ respectExternal: true })],
diff --git a/packages/vitest/src/api/setup.ts b/packages/vitest/src/api/setup.ts
index c743b7afe436..c837d44aba53 100644
--- a/packages/vitest/src/api/setup.ts
+++ b/packages/vitest/src/api/setup.ts
@@ -5,19 +5,14 @@ import { parse, stringify } from 'flatted'
import type { WebSocket } from 'ws'
import { WebSocketServer } from 'ws'
import type { ViteDevServer } from 'vite'
+import type { File, TaskResultPack } from '@vitest/runner'
import { API_PATH } from '../constants'
-import type { Vitest } from '../node'
-import type {
- Awaitable,
- File,
- ModuleGraphData,
- Reporter,
- SerializableSpec,
- TaskResultPack,
- UserConsoleLog,
-} from '../types'
+import type { Vitest } from '../node/core'
+import type { Awaitable, ModuleGraphData, UserConsoleLog } from '../types/general'
+import type { Reporter } from '../node/types/reporter'
import { getModuleGraph, isPrimitive, noop, stringifyReplace } from '../utils'
import { parseErrorStacktrace } from '../utils/source-map'
+import type { SerializedSpec } from '../runtime/types/utils'
import type {
TransformResultWithSource,
WebSocketEvents,
@@ -165,7 +160,7 @@ export class WebSocketReporter implements Reporter {
})
}
- onSpecsCollected(specs?: SerializableSpec[] | undefined): Awaitable {
+ onSpecsCollected(specs?: SerializedSpec[] | undefined): Awaitable {
if (this.clients.size === 0) {
return
}
diff --git a/packages/vitest/src/api/types.ts b/packages/vitest/src/api/types.ts
index 3394b94ed6cd..14102be34761 100644
--- a/packages/vitest/src/api/types.ts
+++ b/packages/vitest/src/api/types.ts
@@ -1,15 +1,28 @@
-import type { TransformResult } from 'vite'
import type { BirpcReturn } from 'birpc'
-import type {
- File,
- ModuleGraphData,
- Reporter,
- SerializableSpec,
- SerializedConfig,
- TaskResultPack,
-} from '../types'
+import type { File, TaskResultPack } from '@vitest/runner'
+import type { Awaitable, ModuleGraphData, UserConsoleLog } from '../types/general'
+import type { SerializedConfig } from '../runtime/config'
+import type { SerializedSpec } from '../runtime/types/utils'
-export interface TransformResultWithSource extends TransformResult {
+interface SourceMap {
+ file: string
+ mappings: string
+ names: string[]
+ sources: string[]
+ sourcesContent?: string[]
+ version: number
+ toString: () => string
+ toUrl: () => string
+}
+
+export interface TransformResultWithSource {
+ code: string
+ map: SourceMap | {
+ mappings: ''
+ } | null
+ etag?: string
+ deps?: string[]
+ dynamicDeps?: string[]
source?: string
}
@@ -17,7 +30,7 @@ export interface WebSocketHandlers {
onCollected: (files?: File[]) => Promise
onTaskUpdate: (packs: TaskResultPack[]) => void
getFiles: () => File[]
- getTestFiles: () => Promise
+ getTestFiles: () => Promise
getPaths: () => string[]
getConfig: () => SerializedConfig
getModuleGraph: (
@@ -37,16 +50,17 @@ export interface WebSocketHandlers {
getUnhandledErrors: () => unknown[]
}
-export interface WebSocketEvents
- extends Pick<
- Reporter,
- | 'onCollected'
- | 'onFinished'
- | 'onTaskUpdate'
- | 'onUserConsoleLog'
- | 'onPathsCollected'
- | 'onSpecsCollected'
- > {
+export interface WebSocketEvents {
+ onCollected?: (files?: File[]) => Awaitable
+ onFinished?: (
+ files: File[],
+ errors: unknown[],
+ coverage?: unknown
+ ) => Awaitable
+ onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable
+ onUserConsoleLog?: (log: UserConsoleLog) => Awaitable
+ onPathsCollected?: (paths?: string[]) => Awaitable
+ onSpecsCollected?: (specs?: SerializedSpec[]) => Awaitable
onFinishedReportCoverage: () => void
}
diff --git a/packages/vitest/src/config.ts b/packages/vitest/src/config.ts
index 4662621393d8..afdec5969889 100644
--- a/packages/vitest/src/config.ts
+++ b/packages/vitest/src/config.ts
@@ -1,5 +1,7 @@
+import './node/types/vite'
+
import type { ConfigEnv, UserConfig as ViteUserConfig } from 'vite'
-import type { ProjectConfig } from './types'
+import type { ProjectConfig } from './node/types/config'
export interface UserWorkspaceConfig extends ViteUserConfig {
test?: ProjectConfig
diff --git a/packages/vitest/src/create/browser/creator.ts b/packages/vitest/src/create/browser/creator.ts
index 0515cdae2348..83443ab85559 100644
--- a/packages/vitest/src/create/browser/creator.ts
+++ b/packages/vitest/src/create/browser/creator.ts
@@ -7,7 +7,7 @@ import type { Agent } from '@antfu/install-pkg'
import { detectPackageManager, installPackage } from '@antfu/install-pkg'
import { findUp } from 'find-up'
import { execa } from 'execa'
-import type { BrowserBuiltinProvider } from '../../types/browser'
+import type { BrowserBuiltinProvider } from '../../node/types/browser'
import { configFiles } from '../../constants'
import { generateExampleFiles } from './examples'
diff --git a/packages/vitest/src/defaults.ts b/packages/vitest/src/defaults.ts
index 96ff8cb7b3a6..f95ad627a036 100644
--- a/packages/vitest/src/defaults.ts
+++ b/packages/vitest/src/defaults.ts
@@ -4,7 +4,7 @@ import type {
CoverageV8Options,
ResolvedCoverageOptions,
UserConfig,
-} from './types'
+} from './node/types/config'
import { isCI } from './utils/env'
export { defaultBrowserPort } from './constants'
diff --git a/packages/vitest/src/environments.ts b/packages/vitest/src/environments.ts
deleted file mode 100644
index 827be772d3c2..000000000000
--- a/packages/vitest/src/environments.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { environments as builtinEnvironments } from './integrations/env/index'
-export { populateGlobal } from './integrations/env/utils'
diff --git a/packages/vitest/src/index.ts b/packages/vitest/src/index.ts
deleted file mode 100644
index 8f898d539282..000000000000
--- a/packages/vitest/src/index.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-export {
- suite,
- test,
- describe,
- it,
- beforeAll,
- beforeEach,
- afterAll,
- afterEach,
- onTestFailed,
- onTestFinished,
-} from '@vitest/runner'
-export { bench } from './runtime/benchmark'
-
-export { runOnce, isFirstRun } from './integrations/run-once'
-export * from './integrations/chai'
-export * from './integrations/vi'
-export * from './integrations/utils'
-export { inject } from './integrations/inject'
-
-export * from './types'
-export * from './api/types'
diff --git a/packages/vitest/src/integrations/chai/index.ts b/packages/vitest/src/integrations/chai/index.ts
index 7c073c570e0c..72ce87d34c5c 100644
--- a/packages/vitest/src/integrations/chai/index.ts
+++ b/packages/vitest/src/integrations/chai/index.ts
@@ -11,10 +11,9 @@ import {
getState,
setState,
} from '@vitest/expect'
-import type { Assertion, ExpectStatic } from '@vitest/expect'
-import type { MatcherState } from '../../types/chai'
+import type { Assertion, ExpectStatic, MatcherState } from '@vitest/expect'
import { getTestName } from '../../utils/tasks'
-import { getCurrentEnvironment, getWorkerState } from '../../utils/global'
+import { getCurrentEnvironment, getWorkerState } from '../../runtime/utils'
import { createExpectPoll } from './poll'
export function createExpect(test?: TaskPopulated) {
diff --git a/packages/vitest/src/integrations/coverage.ts b/packages/vitest/src/integrations/coverage.ts
index cbc6eb6dbcb1..c3c6ed831d05 100644
--- a/packages/vitest/src/integrations/coverage.ts
+++ b/packages/vitest/src/integrations/coverage.ts
@@ -2,7 +2,7 @@ import type { SerializedCoverageConfig } from '../runtime/config'
import type {
CoverageProvider,
CoverageProviderModule,
-} from '../types'
+} from '../node/types/coverage'
interface Loader {
executeId: (id: string) => Promise<{ default: CoverageProviderModule }>
diff --git a/packages/vitest/src/integrations/css/css-modules.ts b/packages/vitest/src/integrations/css/css-modules.ts
index c9a65256a5dc..95a50272989c 100644
--- a/packages/vitest/src/integrations/css/css-modules.ts
+++ b/packages/vitest/src/integrations/css/css-modules.ts
@@ -1,5 +1,5 @@
import { createHash } from 'node:crypto'
-import type { CSSModuleScopeStrategy } from '../../types'
+import type { CSSModuleScopeStrategy } from '../../node/types/config'
export function generateCssFilenameHash(filepath: string) {
return createHash('md5').update(filepath).digest('hex').slice(0, 6)
diff --git a/packages/vitest/src/integrations/env/edge-runtime.ts b/packages/vitest/src/integrations/env/edge-runtime.ts
index 6a4a87021e5b..5e558222cc12 100644
--- a/packages/vitest/src/integrations/env/edge-runtime.ts
+++ b/packages/vitest/src/integrations/env/edge-runtime.ts
@@ -1,4 +1,4 @@
-import type { Environment } from '../../types'
+import type { Environment } from '../../types/environment'
import { populateGlobal } from './utils'
import { KEYS } from './jsdom-keys'
diff --git a/packages/vitest/src/integrations/env/happy-dom.ts b/packages/vitest/src/integrations/env/happy-dom.ts
index 7f3e9a21e5eb..ba7e792c110b 100644
--- a/packages/vitest/src/integrations/env/happy-dom.ts
+++ b/packages/vitest/src/integrations/env/happy-dom.ts
@@ -1,4 +1,4 @@
-import type { Environment } from '../../types'
+import type { Environment } from '../../types/environment'
import { populateGlobal } from './utils'
async function teardownWindow(win: {
diff --git a/packages/vitest/src/integrations/env/index.ts b/packages/vitest/src/integrations/env/index.ts
index 53e538578039..e997962b3fca 100644
--- a/packages/vitest/src/integrations/env/index.ts
+++ b/packages/vitest/src/integrations/env/index.ts
@@ -1,4 +1,3 @@
-import type { VitestEnvironment } from '../../types/config'
import node from './node'
import jsdom from './jsdom'
import happy from './happy-dom'
@@ -12,25 +11,3 @@ export const environments = {
}
export const envs = Object.keys(environments)
-
-export const envPackageNames: Record<
- Exclude,
- string
-> = {
- 'jsdom': 'jsdom',
- 'happy-dom': 'happy-dom',
- 'edge-runtime': '@edge-runtime/vm',
-}
-
-export function getEnvPackageName(env: VitestEnvironment) {
- if (env === 'node') {
- return null
- }
- if (env in envPackageNames) {
- return (envPackageNames as any)[env]
- }
- if (env[0] === '.' || env[0] === '/') {
- return null
- }
- return `vitest-environment-${env}`
-}
diff --git a/packages/vitest/src/integrations/env/jsdom.ts b/packages/vitest/src/integrations/env/jsdom.ts
index 9f554890633a..c772d270813b 100644
--- a/packages/vitest/src/integrations/env/jsdom.ts
+++ b/packages/vitest/src/integrations/env/jsdom.ts
@@ -1,4 +1,4 @@
-import type { Environment } from '../../types'
+import type { Environment } from '../../types/environment'
import { populateGlobal } from './utils'
function catchWindowErrors(window: Window) {
diff --git a/packages/vitest/src/integrations/env/loader.ts b/packages/vitest/src/integrations/env/loader.ts
index 0273abe62660..71df3187346b 100644
--- a/packages/vitest/src/integrations/env/loader.ts
+++ b/packages/vitest/src/integrations/env/loader.ts
@@ -2,8 +2,9 @@ import { readFileSync } from 'node:fs'
import { normalize, resolve } from 'pathe'
import { ViteNodeRunner } from 'vite-node/client'
import type { ViteNodeRunnerOptions } from 'vite-node'
-import type { BuiltinEnvironment, VitestEnvironment } from '../../types/config'
-import type { ContextRPC, Environment, WorkerRPC } from '../../types'
+import type { BuiltinEnvironment, VitestEnvironment } from '../../node/types/config'
+import type { ContextRPC, WorkerRPC } from '../../types/worker'
+import type { Environment } from '../../types/environment'
import { environments } from './index'
function isBuiltinEnvironment(
diff --git a/packages/vitest/src/integrations/env/node.ts b/packages/vitest/src/integrations/env/node.ts
index 843580e10cda..cd4957042baa 100644
--- a/packages/vitest/src/integrations/env/node.ts
+++ b/packages/vitest/src/integrations/env/node.ts
@@ -1,5 +1,5 @@
import { Console } from 'node:console'
-import type { Environment } from '../../types'
+import type { Environment } from '../../types/environment'
// some globals we do not want, either because deprecated or we set it ourselves
const denyList = new Set([
diff --git a/packages/vitest/src/integrations/globals.ts b/packages/vitest/src/integrations/globals.ts
index a017d3e7ac8a..e31212eba223 100644
--- a/packages/vitest/src/integrations/globals.ts
+++ b/packages/vitest/src/integrations/globals.ts
@@ -1,5 +1,5 @@
import { globalApis } from '../constants'
-import * as index from '../index'
+import * as index from '../public/index'
export function registerApiGlobally() {
globalApis.forEach((api) => {
diff --git a/packages/vitest/src/integrations/inject.ts b/packages/vitest/src/integrations/inject.ts
index 1abdf0633e59..076edd562355 100644
--- a/packages/vitest/src/integrations/inject.ts
+++ b/packages/vitest/src/integrations/inject.ts
@@ -1,5 +1,5 @@
import type { ProvidedContext } from '../types/general'
-import { getWorkerState } from '../utils/global'
+import { getWorkerState } from '../runtime/utils'
/**
* Gives access to injected context provided from the main thread.
diff --git a/packages/vitest/src/integrations/run-once.ts b/packages/vitest/src/integrations/run-once.ts
index 6b4f1e322d71..56b602989be3 100644
--- a/packages/vitest/src/integrations/run-once.ts
+++ b/packages/vitest/src/integrations/run-once.ts
@@ -1,4 +1,4 @@
-import { getWorkerState } from '../utils/global'
+import { getWorkerState } from '../runtime/utils'
const filesCount = new Map()
const cache = new Map()
diff --git a/packages/vitest/src/integrations/vi.ts b/packages/vitest/src/integrations/vi.ts
index 1f49ed2019c3..7c3133188bdc 100644
--- a/packages/vitest/src/integrations/vi.ts
+++ b/packages/vitest/src/integrations/vi.ts
@@ -4,7 +4,7 @@ import { parseSingleStack } from '../utils/source-map'
import type { VitestMocker } from '../runtime/mocker'
import type { RuntimeOptions, SerializedConfig } from '../runtime/config'
import type { MockFactoryWithHelper } from '../types/mocker'
-import { getWorkerState } from '../utils/global'
+import { getWorkerState } from '../runtime/utils'
import { resetModules, waitForImportsToResolve } from '../utils/modules'
import { isChildProcess } from '../utils/base'
import { FakeTimers } from './mock/timers'
diff --git a/packages/vitest/src/node.ts b/packages/vitest/src/node.ts
deleted file mode 100644
index 4b4ba696627c..000000000000
--- a/packages/vitest/src/node.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './node/index'
diff --git a/packages/vitest/src/node/cache/results.ts b/packages/vitest/src/node/cache/results.ts
index 84f2e09794a6..6bdafb64526a 100644
--- a/packages/vitest/src/node/cache/results.ts
+++ b/packages/vitest/src/node/cache/results.ts
@@ -1,7 +1,7 @@
import fs from 'node:fs'
import { dirname, relative, resolve } from 'pathe'
-import type { File } from '../../types'
-import type { ResolvedConfig } from '../../types/config'
+import type { File } from '@vitest/runner'
+import type { ResolvedConfig } from '../types/config'
export interface SuiteResultCache {
failed: boolean
diff --git a/packages/vitest/src/node/cli/cac.ts b/packages/vitest/src/node/cli/cac.ts
index 9a56c772fa0c..e2fcc55c2030 100644
--- a/packages/vitest/src/node/cli/cac.ts
+++ b/packages/vitest/src/node/cli/cac.ts
@@ -3,7 +3,7 @@ import cac, { type CAC, type Command } from 'cac'
import c from 'tinyrainbow'
import { version } from '../../../package.json' with { type: 'json' }
import { toArray } from '../../utils/base'
-import type { VitestRunMode } from '../../types'
+import type { VitestRunMode } from '../types/config'
import type { CliOptions } from './cli-api'
import type { CLIOption, CLIOptions as CLIOptionsConfig } from './cli-config'
import { benchCliOptionsConfig, cliOptionsConfig, collectCliOptionsConfig } from './cli-config'
diff --git a/packages/vitest/src/node/cli/cli-api.ts b/packages/vitest/src/node/cli/cli-api.ts
index 197ae804f25f..c9e3576fabe2 100644
--- a/packages/vitest/src/node/cli/cli-api.ts
+++ b/packages/vitest/src/node/cli/cli-api.ts
@@ -5,13 +5,13 @@ import { dirname, resolve } from 'pathe'
import type { UserConfig as ViteUserConfig } from 'vite'
import type { File, Suite, Task } from '@vitest/runner'
import { CoverageProviderMap } from '../../integrations/coverage'
-import { getEnvPackageName } from '../../integrations/env'
-import type { UserConfig, Vitest, VitestRunMode } from '../../types'
+import type { environments } from '../../integrations/env'
import { createVitest } from '../create'
import { registerConsoleShortcuts } from '../stdin'
-import type { VitestOptions } from '../core'
+import type { Vitest, VitestOptions } from '../core'
import { FilesNotFoundError, GitNotFoundError } from '../errors'
import { getNames, getTests } from '../../utils'
+import type { UserConfig, VitestEnvironment, VitestRunMode } from '../types/config'
export interface CliOptions extends UserConfig {
/**
@@ -236,3 +236,25 @@ export function formatCollectedAsString(files: File[]) {
})
}).flat()
}
+
+const envPackageNames: Record<
+ Exclude,
+ string
+> = {
+ 'jsdom': 'jsdom',
+ 'happy-dom': 'happy-dom',
+ 'edge-runtime': '@edge-runtime/vm',
+}
+
+function getEnvPackageName(env: VitestEnvironment) {
+ if (env === 'node') {
+ return null
+ }
+ if (env in envPackageNames) {
+ return (envPackageNames as any)[env]
+ }
+ if (env[0] === '.' || env[0] === '/') {
+ return null
+ }
+ return `vitest-environment-${env}`
+}
diff --git a/packages/vitest/src/node/cli/cli-config.ts b/packages/vitest/src/node/cli/cli-config.ts
index fa980b08a7d4..ade1b3a385b7 100644
--- a/packages/vitest/src/node/cli/cli-config.ts
+++ b/packages/vitest/src/node/cli/cli-config.ts
@@ -1,11 +1,11 @@
import { defaultBrowserPort, defaultPort } from '../../constants'
-import type { ApiConfig } from '../../types/config'
+import type { ApiConfig } from '../types/config'
import type {
ForksOptions,
ThreadsOptions,
VmOptions,
WorkerContextOptions,
-} from '../../types/pool-options'
+} from '../types/pool-options'
import type { CliOptions } from './cli-api'
type NestedOption>> = V extends
diff --git a/packages/vitest/src/node/config/resolveConfig.ts b/packages/vitest/src/node/config/resolveConfig.ts
index 44728cfe7cda..c9745317388d 100644
--- a/packages/vitest/src/node/config/resolveConfig.ts
+++ b/packages/vitest/src/node/config/resolveConfig.ts
@@ -7,7 +7,7 @@ import type {
ResolvedConfig,
UserConfig,
VitestRunMode,
-} from '../../types/config'
+} from '../types/config'
import {
defaultBrowserPort,
defaultInspectPort,
@@ -16,7 +16,7 @@ import {
} from '../../constants'
import { benchmarkConfigDefaults, configDefaults } from '../../defaults'
import { isCI, stdProvider, toArray } from '../../utils'
-import type { BuiltinPool, ForksOptions, PoolOptions, ThreadsOptions } from '../../types/pool-options'
+import type { BuiltinPool, ForksOptions, PoolOptions, ThreadsOptions } from '../types/pool-options'
import { getWorkersCountByPercentage } from '../../utils/workers'
import { VitestCache } from '../cache'
import { BaseSequencer } from '../sequencers/BaseSequencer'
diff --git a/packages/vitest/src/node/config/serializeConfig.ts b/packages/vitest/src/node/config/serializeConfig.ts
index 9d1e0b0ef6a5..15d1a06103ea 100644
--- a/packages/vitest/src/node/config/serializeConfig.ts
+++ b/packages/vitest/src/node/config/serializeConfig.ts
@@ -1,5 +1,5 @@
import type { ResolvedConfig as ViteConfig } from 'vite'
-import type { ResolvedConfig, SerializedConfig } from '../../types/config'
+import type { ResolvedConfig, SerializedConfig } from '../types/config'
export function serializeConfig(
config: ResolvedConfig,
diff --git a/packages/vitest/src/node/core.ts b/packages/vitest/src/node/core.ts
index b4f328ed7d41..e1967d78daa0 100644
--- a/packages/vitest/src/node/core.ts
+++ b/packages/vitest/src/node/core.ts
@@ -12,13 +12,14 @@ import type { CancelReason, File, TaskResultPack } from '@vitest/runner'
import { ViteNodeServer } from 'vite-node/server'
import type { defineWorkspace } from 'vitest/config'
import { version } from '../../package.json' with { type: 'json' }
-import type { ArgumentsType, CoverageProvider, OnServerRestartHandler, ProvidedContext, Reporter, ResolvedConfig, SerializableSpec, UserConfig, UserConsoleLog, UserWorkspaceConfig, VitestRunMode } from '../types'
import { getTasks, hasFailed, noop, slash, toArray, wildcardPatternToRegExp } from '../utils'
import { getCoverageProvider } from '../integrations/coverage'
import { CONFIG_NAMES, configFiles, workspacesFiles as workspaceFiles } from '../constants'
import { rootDir } from '../paths'
import { WebSocketReporter } from '../api/setup'
import type { SerializedCoverageConfig } from '../runtime/config'
+import type { SerializedSpec } from '../runtime/types/utils'
+import type { ArgumentsType, OnServerRestartHandler, ProvidedContext, UserConsoleLog } from '../types/general'
import { createPool } from './pool'
import type { ProcessPool, WorkspaceSpec } from './pool'
import { createBenchmarkReporters, createReporters } from './reporters/utils'
@@ -30,6 +31,9 @@ import { WorkspaceProject, initializeProject } from './workspace'
import { VitestPackageInstaller } from './packageInstaller'
import { BlobReporter, readBlobs } from './reporters/blob'
import { FilesNotFoundError, GitNotFoundError } from './errors'
+import type { ResolvedConfig, UserConfig, UserWorkspaceConfig, VitestRunMode } from './types/config'
+import type { Reporter } from './types/reporter'
+import type { CoverageProvider } from './types/coverage'
const WATCHER_DEBOUNCE = 100
@@ -671,7 +675,7 @@ export class Vitest {
await this.report('onPathsCollected', filepaths)
await this.report('onSpecsCollected', specs.map(
([project, file]) =>
- [{ name: project.config.name, root: project.config.root }, file] as SerializableSpec,
+ [{ name: project.config.name, root: project.config.root }, file] as SerializedSpec,
))
// previous run
diff --git a/packages/vitest/src/node/create.ts b/packages/vitest/src/node/create.ts
index 830c91a13b80..2c7dc0a2545a 100644
--- a/packages/vitest/src/node/create.ts
+++ b/packages/vitest/src/node/create.ts
@@ -5,12 +5,12 @@ import type {
UserConfig as ViteUserConfig,
} from 'vite'
import { findUp } from 'find-up'
-import type { UserConfig, VitestRunMode } from '../types'
import { configFiles } from '../constants'
import type { VitestOptions } from './core'
import { Vitest } from './core'
import { VitestPlugin } from './plugins'
import { createViteServer } from './vite'
+import type { UserConfig, VitestRunMode } from './types/config'
export async function createVitest(
mode: VitestRunMode,
diff --git a/packages/vitest/src/node/error.ts b/packages/vitest/src/node/error.ts
index cfbbb3750d7e..d0f07767823d 100644
--- a/packages/vitest/src/node/error.ts
+++ b/packages/vitest/src/node/error.ts
@@ -4,9 +4,9 @@ import { Writable } from 'node:stream'
import { normalize, relative } from 'pathe'
import c from 'tinyrainbow'
import cliTruncate from 'cli-truncate'
+import type { ErrorWithDiff, ParsedStack } from '@vitest/utils'
import { inspect } from '@vitest/utils'
import stripAnsi from 'strip-ansi'
-import type { ErrorWithDiff, ParsedStack } from '../types'
import {
lineSplitRE,
positionToOffset,
diff --git a/packages/vitest/src/node/globalSetup.ts b/packages/vitest/src/node/globalSetup.ts
index 310c8949770a..154881e5b4f9 100644
--- a/packages/vitest/src/node/globalSetup.ts
+++ b/packages/vitest/src/node/globalSetup.ts
@@ -1,7 +1,7 @@
import { toArray } from '@vitest/utils'
import type { ViteNodeRunner } from 'vite-node/client'
import type { ProvidedContext } from '../types/general'
-import type { ResolvedConfig } from '../types/config'
+import type { ResolvedConfig } from './types/config'
export interface GlobalSetupContext {
config: ResolvedConfig
diff --git a/packages/vitest/src/node/index.ts b/packages/vitest/src/node/index.ts
deleted file mode 100644
index 77883c113e4c..000000000000
--- a/packages/vitest/src/node/index.ts
+++ /dev/null
@@ -1,73 +0,0 @@
-export type { Vitest } from './core'
-export type { WorkspaceProject } from './workspace'
-export { createVitest } from './create'
-export { VitestPlugin } from './plugins'
-export { startVitest } from './cli/cli-api'
-export { parseCLI } from './cli/cac'
-export { registerConsoleShortcuts } from './stdin'
-export type { GlobalSetupContext } from './globalSetup'
-export type { WorkspaceSpec, ProcessPool } from './pool'
-export { createMethodsRPC } from './pools/rpc'
-export { getFilePoolName } from './pool'
-export { VitestPackageInstaller } from './packageInstaller'
-export { createDebugger } from '../utils/debugger'
-export { resolveFsAllow } from './plugins/utils'
-export { resolveApiServerConfig, resolveConfig } from './config/resolveConfig'
-
-export { GitNotFoundError, FilesNotFoundError as TestsNotFoundError } from './errors'
-
-export { distDir, rootDir } from '../paths'
-
-export type {
- TestSequencer,
- TestSequencerConstructor,
-} from './sequencers/types'
-export { BaseSequencer } from './sequencers/BaseSequencer'
-
-export type {
- BrowserProviderInitializationOptions,
- BrowserProvider,
- CDPSession,
- BrowserProviderModule,
- ResolvedBrowserOptions,
- BrowserProviderOptions,
- BrowserBuiltinProvider,
- BrowserScript,
- BrowserCommand,
- BrowserCommandContext,
- BrowserServer,
- BrowserServerState,
- BrowserServerStateContext,
- BrowserOrchestrator,
- BrowserConfigOptions,
-} from '../types/browser'
-export type { JsonOptions } from './reporters/json'
-export type { JUnitOptions } from './reporters/junit'
-export type { HTMLOptions } from './reporters/html'
-
-export { isFileServingAllowed, createServer, parseAst, parseAstAsync } from 'vite'
-export type * as Vite from 'vite'
-
-export type {
- SequenceHooks,
- SequenceSetupFiles,
- BuiltinEnvironment,
- VitestEnvironment,
- Pool,
- PoolOptions,
- CSSModuleScopeStrategy,
- ApiConfig,
- JSDOMOptions,
- HappyDOMOptions,
- EnvironmentOptions,
- VitestRunMode,
- DepsOptimizationOptions,
- TransformModePatterns,
- InlineConfig,
- TypecheckConfig,
- UserConfig,
- ResolvedConfig,
- ProjectConfig,
- UserWorkspaceConfig,
- RuntimeConfig,
-} from '../types/config'
diff --git a/packages/vitest/src/node/logger.ts b/packages/vitest/src/node/logger.ts
index b963b744d50b..475a74619d20 100644
--- a/packages/vitest/src/node/logger.ts
+++ b/packages/vitest/src/node/logger.ts
@@ -3,7 +3,8 @@ import type { Writable } from 'node:stream'
import { createLogUpdate } from 'log-update'
import c from 'tinyrainbow'
import { parseErrorStacktrace } from '@vitest/utils/source-map'
-import type { ErrorWithDiff, Task } from '../types'
+import type { Task } from '@vitest/runner'
+import type { ErrorWithDiff } from '@vitest/utils'
import type { TypeCheckError } from '../typecheck/typechecker'
import { toArray } from '../utils'
import { highlightCode } from '../utils/colors'
diff --git a/packages/vitest/src/node/plugins/cssEnabler.ts b/packages/vitest/src/node/plugins/cssEnabler.ts
index 6cfebe072b06..c4d577bc1106 100644
--- a/packages/vitest/src/node/plugins/cssEnabler.ts
+++ b/packages/vitest/src/node/plugins/cssEnabler.ts
@@ -1,7 +1,7 @@
import { relative } from 'pathe'
import type { Plugin as VitePlugin } from 'vite'
import { generateCssFilenameHash } from '../../integrations/css/css-modules'
-import type { CSSModuleScopeStrategy, ResolvedConfig } from '../../types/config'
+import type { CSSModuleScopeStrategy, ResolvedConfig } from '../types/config'
import { toArray } from '../../utils'
const cssLangs = '\\.(?:css|less|sass|scss|styl|stylus|pcss|postcss)(?:$|\\?)'
diff --git a/packages/vitest/src/node/plugins/index.ts b/packages/vitest/src/node/plugins/index.ts
index dcbc807b125d..e30d1c64cda4 100644
--- a/packages/vitest/src/node/plugins/index.ts
+++ b/packages/vitest/src/node/plugins/index.ts
@@ -1,7 +1,7 @@
import type { UserConfig as ViteConfig, Plugin as VitePlugin } from 'vite'
import { relative } from 'pathe'
import { configDefaults, coverageConfigDefaults } from '../../defaults'
-import type { ResolvedConfig, UserConfig } from '../../types/config'
+import type { ResolvedConfig, UserConfig } from '../types/config'
import {
deepMerge,
notNullish,
diff --git a/packages/vitest/src/node/plugins/utils.ts b/packages/vitest/src/node/plugins/utils.ts
index 10bc534c0b08..63edb936c915 100644
--- a/packages/vitest/src/node/plugins/utils.ts
+++ b/packages/vitest/src/node/plugins/utils.ts
@@ -5,7 +5,7 @@ import type {
UserConfig as ViteConfig,
} from 'vite'
import { dirname } from 'pathe'
-import type { DepsOptimizationOptions, InlineConfig } from '../../types/config'
+import type { DepsOptimizationOptions, InlineConfig } from '../types/config'
import { VitestCache } from '../cache'
import { rootDir } from '../../paths'
diff --git a/packages/vitest/src/node/plugins/workspace.ts b/packages/vitest/src/node/plugins/workspace.ts
index 7dc2cd3f1ca5..768f4ad1445f 100644
--- a/packages/vitest/src/node/plugins/workspace.ts
+++ b/packages/vitest/src/node/plugins/workspace.ts
@@ -5,7 +5,7 @@ import { configDefaults } from '../../defaults'
import { generateScopedClassName } from '../../integrations/css/css-modules'
import { deepMerge } from '../../utils/base'
import type { WorkspaceProject } from '../workspace'
-import type { ResolvedConfig, UserWorkspaceConfig } from '../../types/config'
+import type { ResolvedConfig, UserWorkspaceConfig } from '../types/config'
import { CoverageTransform } from './coverageTransform'
import { CSSEnablerPlugin } from './cssEnabler'
import { SsrReplacerPlugin } from './ssrReplacer'
diff --git a/packages/vitest/src/node/pool.ts b/packages/vitest/src/node/pool.ts
index 5dd244fea431..a8d7b0b2d0d0 100644
--- a/packages/vitest/src/node/pool.ts
+++ b/packages/vitest/src/node/pool.ts
@@ -1,7 +1,7 @@
import mm from 'micromatch'
import type { Awaitable } from '@vitest/utils'
-import type { BuiltinPool, Pool } from '../types/pool-options'
import { isWindows } from '../utils/env'
+import type { BuiltinPool, Pool } from './types/pool-options'
import type { Vitest } from './core'
import { createForksPool } from './pools/forks'
import { createThreadsPool } from './pools/threads'
diff --git a/packages/vitest/src/node/pools/forks.ts b/packages/vitest/src/node/pools/forks.ts
index 797106d99326..69a8de2c706b 100644
--- a/packages/vitest/src/node/pools/forks.ts
+++ b/packages/vitest/src/node/pools/forks.ts
@@ -4,19 +4,15 @@ import EventEmitter from 'node:events'
import { Tinypool } from 'tinypool'
import type { TinypoolChannel, Options as TinypoolOptions } from 'tinypool'
import { createBirpc } from 'birpc'
-import type {
- ContextRPC,
- ContextTestEnvironment,
- RunnerRPC,
- RuntimeRPC,
- Vitest,
-} from '../../types'
import type { PoolProcessOptions, ProcessPool, RunWithFiles } from '../pool'
import type { WorkspaceProject } from '../workspace'
import { envsOrder, groupFilesByEnv } from '../../utils/test-helpers'
import { wrapSerializableConfig } from '../../utils/config-helpers'
import { groupBy, resolve } from '../../utils'
-import type { SerializedConfig } from '../../types/config'
+import type { SerializedConfig } from '../types/config'
+import type { RunnerRPC, RuntimeRPC } from '../../types/rpc'
+import type { Vitest } from '../core'
+import type { ContextRPC, ContextTestEnvironment } from '../../types/worker'
import { createMethodsRPC } from './rpc'
function createChildProcessChannel(project: WorkspaceProject) {
diff --git a/packages/vitest/src/node/pools/rpc.ts b/packages/vitest/src/node/pools/rpc.ts
index 3ce3324bb27e..32196af49e72 100644
--- a/packages/vitest/src/node/pools/rpc.ts
+++ b/packages/vitest/src/node/pools/rpc.ts
@@ -2,8 +2,8 @@ import { createHash } from 'node:crypto'
import { mkdir, writeFile } from 'node:fs/promises'
import type { RawSourceMap } from 'vite-node'
import { join } from 'pathe'
-import type { RuntimeRPC } from '../../types'
import type { WorkspaceProject } from '../workspace'
+import type { RuntimeRPC } from '../../types/rpc'
const created = new Set()
const promises = new Map>()
diff --git a/packages/vitest/src/node/pools/threads.ts b/packages/vitest/src/node/pools/threads.ts
index 02f28bb3f989..c76109baf492 100644
--- a/packages/vitest/src/node/pools/threads.ts
+++ b/packages/vitest/src/node/pools/threads.ts
@@ -4,18 +4,15 @@ import { createBirpc } from 'birpc'
import type { Options as TinypoolOptions } from 'tinypool'
import Tinypool from 'tinypool'
import { resolve } from 'pathe'
-import type {
- ContextTestEnvironment,
- RunnerRPC,
- RuntimeRPC,
- Vitest,
- WorkerContext,
-} from '../../types'
import type { PoolProcessOptions, ProcessPool, RunWithFiles } from '../pool'
import { envsOrder, groupFilesByEnv } from '../../utils/test-helpers'
import { AggregateError, groupBy } from '../../utils/base'
import type { WorkspaceProject } from '../workspace'
-import type { SerializedConfig } from '../../types/config'
+import type { SerializedConfig } from '../types/config'
+import type { RunnerRPC, RuntimeRPC } from '../../types/rpc'
+import type { ContextTestEnvironment } from '../../types/worker'
+import type { Vitest } from '../core'
+import type { WorkerContext } from '../types/worker'
import { createMethodsRPC } from './rpc'
function createWorkerChannel(project: WorkspaceProject) {
diff --git a/packages/vitest/src/node/pools/vmForks.ts b/packages/vitest/src/node/pools/vmForks.ts
index 03ff54ea7f39..46ea4c3c96b6 100644
--- a/packages/vitest/src/node/pools/vmForks.ts
+++ b/packages/vitest/src/node/pools/vmForks.ts
@@ -6,21 +6,16 @@ import { resolve } from 'pathe'
import type { TinypoolChannel, Options as TinypoolOptions } from 'tinypool'
import Tinypool from 'tinypool'
import { rootDir } from '../../paths'
-import type {
- ContextRPC,
- ContextTestEnvironment,
- ResolvedConfig,
- RunnerRPC,
- RuntimeRPC,
- Vitest,
-} from '../../types'
import type { PoolProcessOptions, ProcessPool, RunWithFiles } from '../pool'
import { groupFilesByEnv } from '../../utils/test-helpers'
import { AggregateError } from '../../utils/base'
import type { WorkspaceProject } from '../workspace'
import { getWorkerMemoryLimit, stringToBytes } from '../../utils/memory-limit'
import { wrapSerializableConfig } from '../../utils/config-helpers'
-import type { SerializedConfig } from '../../types/config'
+import type { ResolvedConfig, SerializedConfig } from '../types/config'
+import type { RunnerRPC, RuntimeRPC } from '../../types/rpc'
+import type { Vitest } from '../core'
+import type { ContextRPC, ContextTestEnvironment } from '../../types/worker'
import { createMethodsRPC } from './rpc'
const suppressWarningsPath = resolve(rootDir, './suppress-warnings.cjs')
diff --git a/packages/vitest/src/node/pools/vmThreads.ts b/packages/vitest/src/node/pools/vmThreads.ts
index 2758c81396d2..ea245696db89 100644
--- a/packages/vitest/src/node/pools/vmThreads.ts
+++ b/packages/vitest/src/node/pools/vmThreads.ts
@@ -5,20 +5,16 @@ import { resolve } from 'pathe'
import type { Options as TinypoolOptions } from 'tinypool'
import Tinypool from 'tinypool'
import { rootDir } from '../../paths'
-import type {
- ContextTestEnvironment,
- ResolvedConfig,
- RunnerRPC,
- RuntimeRPC,
- Vitest,
- WorkerContext,
-} from '../../types'
import type { PoolProcessOptions, ProcessPool, RunWithFiles } from '../pool'
import { groupFilesByEnv } from '../../utils/test-helpers'
import { AggregateError } from '../../utils/base'
import type { WorkspaceProject } from '../workspace'
import { getWorkerMemoryLimit, stringToBytes } from '../../utils/memory-limit'
-import type { SerializedConfig } from '../../types/config'
+import type { ResolvedConfig, SerializedConfig } from '../types/config'
+import type { RunnerRPC, RuntimeRPC } from '../../types/rpc'
+import type { ContextTestEnvironment } from '../../types/worker'
+import type { Vitest } from '../core'
+import type { WorkerContext } from '../types/worker'
import { createMethodsRPC } from './rpc'
const suppressWarningsPath = resolve(rootDir, './suppress-warnings.cjs')
diff --git a/packages/vitest/src/node/reporters/base.ts b/packages/vitest/src/node/reporters/base.ts
index fe8a099cb47a..702e0bc17f82 100644
--- a/packages/vitest/src/node/reporters/base.ts
+++ b/packages/vitest/src/node/reporters/base.ts
@@ -2,14 +2,7 @@ import { performance } from 'node:perf_hooks'
import c from 'tinyrainbow'
import { parseStacktrace } from '@vitest/utils/source-map'
import { relative } from 'pathe'
-import type {
- ErrorWithDiff,
- File,
- Reporter,
- Task,
- TaskResultPack,
- UserConsoleLog,
-} from '../../types'
+import type { File, Task, TaskResultPack } from '@vitest/runner'
import {
getFullName,
getSuites,
@@ -23,9 +16,10 @@ import {
relativePath,
toArray,
} from '../../utils'
-import type { Vitest } from '../../node'
+import type { Vitest } from '../core'
import { F_POINTER, F_RIGHT } from '../../utils/figures'
-import { UNKNOWN_TEST_ID } from '../../runtime/console'
+import type { Reporter } from '../types/reporter'
+import type { ErrorWithDiff, UserConsoleLog } from '../../types/general'
import {
countTestErrors,
divider,
@@ -303,7 +297,7 @@ export abstract class BaseReporter implements Reporter {
` | ${
task
? getFullName(task, c.dim(' > '))
- : log.taskId !== UNKNOWN_TEST_ID
+ : log.taskId !== '__vitest__unknown_test__'
? log.taskId
: 'unknown test'
}`,
diff --git a/packages/vitest/src/node/reporters/basic.ts b/packages/vitest/src/node/reporters/basic.ts
index 9f4438102bf8..f93b2325798c 100644
--- a/packages/vitest/src/node/reporters/basic.ts
+++ b/packages/vitest/src/node/reporters/basic.ts
@@ -1,4 +1,4 @@
-import type { File } from '../../types/tasks'
+import type { File } from '@vitest/runner'
import { BaseReporter } from './base'
export class BasicReporter extends BaseReporter {
diff --git a/packages/vitest/src/node/reporters/benchmark/table/index.ts b/packages/vitest/src/node/reporters/benchmark/table/index.ts
index 1174a37e5259..99dae30d86a2 100644
--- a/packages/vitest/src/node/reporters/benchmark/table/index.ts
+++ b/packages/vitest/src/node/reporters/benchmark/table/index.ts
@@ -1,12 +1,12 @@
import fs from 'node:fs'
import c from 'tinyrainbow'
import * as pathe from 'pathe'
-import type { TaskResultPack } from '@vitest/runner'
+import type { File, TaskResultPack } from '@vitest/runner'
import type { UserConsoleLog } from '../../../../types/general'
import { BaseReporter } from '../../base'
-import type { BenchmarkResult, File } from '../../../../types'
import { getFullName, getTasks } from '../../../../utils'
import { getStateSymbol } from '../../renderers/utils'
+import type { BenchmarkResult } from '../../../../runtime/types/benchmark'
import {
type TableRendererOptions,
createTableRenderer,
diff --git a/packages/vitest/src/node/reporters/benchmark/table/tableRender.ts b/packages/vitest/src/node/reporters/benchmark/table/tableRender.ts
index 51458fb4a174..1eb9e1bca8f6 100644
--- a/packages/vitest/src/node/reporters/benchmark/table/tableRender.ts
+++ b/packages/vitest/src/node/reporters/benchmark/table/tableRender.ts
@@ -1,11 +1,12 @@
import c from 'tinyrainbow'
import cliTruncate from 'cli-truncate'
import stripAnsi from 'strip-ansi'
-import type { BenchmarkResult, Task } from '../../../../types'
+import type { Task } from '@vitest/runner'
import { getTests, notNullish } from '../../../../utils'
import { F_RIGHT } from '../../../../utils/figures'
import type { Logger } from '../../../logger'
import { getCols, getStateSymbol } from '../../renderers/utils'
+import type { BenchmarkResult } from '../../../../runtime/types/benchmark'
import type { FlatBenchmarkReport } from '.'
export interface TableRendererOptions {
diff --git a/packages/vitest/src/node/reporters/blob.ts b/packages/vitest/src/node/reporters/blob.ts
index 6eb32af179c0..4f780e93fa6f 100644
--- a/packages/vitest/src/node/reporters/blob.ts
+++ b/packages/vitest/src/node/reporters/blob.ts
@@ -3,9 +3,11 @@ import { existsSync } from 'node:fs'
import { parse, stringify } from 'flatted'
import { dirname, resolve } from 'pathe'
import { cleanUrl } from 'vite-node/utils'
-import type { File, Reporter, Vitest } from '../../types'
+import type { File } from '@vitest/runner'
import { getOutputFile } from '../../utils/config-helpers'
import type { WorkspaceProject } from '../workspace'
+import type { Reporter } from '../types/reporter'
+import type { Vitest } from '../core'
export interface BlobOptions {
outputFile?: string
diff --git a/packages/vitest/src/node/reporters/github-actions.ts b/packages/vitest/src/node/reporters/github-actions.ts
index 3fbe2a188ba3..606f593ebcef 100644
--- a/packages/vitest/src/node/reporters/github-actions.ts
+++ b/packages/vitest/src/node/reporters/github-actions.ts
@@ -1,9 +1,11 @@
import { getTasks } from '@vitest/runner/utils'
import stripAnsi from 'strip-ansi'
-import type { File, Reporter, Vitest } from '../../types'
+import type { File } from '@vitest/runner'
import { getFullName } from '../../utils'
import { capturePrintError } from '../error'
import type { WorkspaceProject } from '../workspace'
+import type { Reporter } from '../types/reporter'
+import type { Vitest } from '../core'
export class GithubActionsReporter implements Reporter {
ctx: Vitest = undefined!
diff --git a/packages/vitest/src/node/reporters/hanging-process.ts b/packages/vitest/src/node/reporters/hanging-process.ts
index 8e9b83a57f2c..d5d9ab12f7ac 100644
--- a/packages/vitest/src/node/reporters/hanging-process.ts
+++ b/packages/vitest/src/node/reporters/hanging-process.ts
@@ -1,5 +1,5 @@
import { createRequire } from 'node:module'
-import type { Reporter } from '../../types'
+import type { Reporter } from '../types/reporter'
export class HangingProcessReporter implements Reporter {
whyRunning: (() => void) | undefined
diff --git a/packages/vitest/src/node/reporters/index.ts b/packages/vitest/src/node/reporters/index.ts
index 3a967cb4c8ef..37000f174bbb 100644
--- a/packages/vitest/src/node/reporters/index.ts
+++ b/packages/vitest/src/node/reporters/index.ts
@@ -1,4 +1,4 @@
-import type { Reporter } from '../../types'
+import type { Reporter } from '../types/reporter'
import { BasicReporter } from './basic'
import { DefaultReporter } from './default'
import { DotReporter } from './dot'
diff --git a/packages/vitest/src/node/reporters/json.ts b/packages/vitest/src/node/reporters/json.ts
index ac1a2c984ba3..cdad5ed22bd1 100644
--- a/packages/vitest/src/node/reporters/json.ts
+++ b/packages/vitest/src/node/reporters/json.ts
@@ -1,16 +1,11 @@
import { existsSync, promises as fs } from 'node:fs'
import { dirname, resolve } from 'pathe'
-import type { Vitest } from '../../node'
-import type {
- File,
- Reporter,
- SnapshotSummary,
- Suite,
- TaskMeta,
- TaskState,
-} from '../../types'
+import type { File, Suite, TaskMeta, TaskState } from '@vitest/runner'
+import type { SnapshotSummary } from '@vitest/snapshot'
import { getSuites, getTests } from '../../utils'
import { getOutputFile } from '../../utils/config-helpers'
+import type { Reporter } from '../types/reporter'
+import type { Vitest } from '../core'
// for compatibility reasons, the reporter produces a JSON similar to the one produced by the Jest JSON reporter
// the following types are extracted from the Jest repository (and simplified)
diff --git a/packages/vitest/src/node/reporters/junit.ts b/packages/vitest/src/node/reporters/junit.ts
index 5b5c4a2dcf1e..942ecbacc739 100644
--- a/packages/vitest/src/node/reporters/junit.ts
+++ b/packages/vitest/src/node/reporters/junit.ts
@@ -5,8 +5,8 @@ import { dirname, relative, resolve } from 'pathe'
import type { Task } from '@vitest/runner'
import { getSuites } from '@vitest/runner/utils'
import stripAnsi from 'strip-ansi'
-import type { Vitest } from '../../node'
-import type { Reporter } from '../../types/reporter'
+import type { Vitest } from '../core'
+import type { Reporter } from '../types/reporter'
import { getOutputFile } from '../../utils/config-helpers'
import { capturePrintError } from '../error'
import { IndentedLogger } from './renderers/indented-logger'
diff --git a/packages/vitest/src/node/reporters/renderers/dotRenderer.ts b/packages/vitest/src/node/reporters/renderers/dotRenderer.ts
index 2c8f6ca4da98..2de99b01a081 100644
--- a/packages/vitest/src/node/reporters/renderers/dotRenderer.ts
+++ b/packages/vitest/src/node/reporters/renderers/dotRenderer.ts
@@ -1,5 +1,5 @@
import c from 'tinyrainbow'
-import type { Task } from '../../../types'
+import type { Task } from '@vitest/runner'
import { getTests } from '../../../utils'
import type { Logger } from '../../logger'
diff --git a/packages/vitest/src/node/reporters/renderers/listRenderer.ts b/packages/vitest/src/node/reporters/renderers/listRenderer.ts
index a13841071936..6eedf6c55836 100644
--- a/packages/vitest/src/node/reporters/renderers/listRenderer.ts
+++ b/packages/vitest/src/node/reporters/renderers/listRenderer.ts
@@ -1,16 +1,12 @@
import c from 'tinyrainbow'
import cliTruncate from 'cli-truncate'
import stripAnsi from 'strip-ansi'
-import type {
- Benchmark,
- BenchmarkResult,
- SuiteHooks,
- Task,
- VitestRunMode,
-} from '../../../types'
+import type { SuiteHooks, Task } from '@vitest/runner'
import { getTests, notNullish } from '../../../utils'
import { F_RIGHT } from '../../../utils/figures'
import type { Logger } from '../../logger'
+import type { VitestRunMode } from '../../types/config'
+import type { Benchmark, BenchmarkResult } from '../../../runtime/types/benchmark'
import {
formatProjectName,
getCols,
diff --git a/packages/vitest/src/node/reporters/renderers/utils.ts b/packages/vitest/src/node/reporters/renderers/utils.ts
index eb770bfff4da..9c8212944a70 100644
--- a/packages/vitest/src/node/reporters/renderers/utils.ts
+++ b/packages/vitest/src/node/reporters/renderers/utils.ts
@@ -1,7 +1,8 @@
import { basename, dirname, isAbsolute, relative } from 'pathe'
import c from 'tinyrainbow'
import stripAnsi from 'strip-ansi'
-import type { SnapshotSummary, Task } from '../../../types'
+import type { SuiteHooks, Task } from '@vitest/runner'
+import type { SnapshotSummary } from '@vitest/snapshot'
import { slash } from '../../../utils/base'
import {
F_CHECK,
@@ -12,7 +13,6 @@ import {
F_LONG_DASH,
F_POINTER,
} from '../../../utils/figures'
-import type { SuiteHooks } from './../../../types/tasks'
export const spinnerMap = new WeakMap string>()
export const hookSpinnerMap = new WeakMap string>>()
diff --git a/packages/vitest/src/node/reporters/tap-flat.ts b/packages/vitest/src/node/reporters/tap-flat.ts
index da93d9cf2abe..a5905d5e42ca 100644
--- a/packages/vitest/src/node/reporters/tap-flat.ts
+++ b/packages/vitest/src/node/reporters/tap-flat.ts
@@ -1,5 +1,5 @@
import type { Task } from '@vitest/runner'
-import type { Vitest } from '../../node'
+import type { Vitest } from '../core'
import { TapReporter } from './tap'
function flattenTasks(task: Task, baseName = ''): Task[] {
diff --git a/packages/vitest/src/node/reporters/tap.ts b/packages/vitest/src/node/reporters/tap.ts
index e9ab48e4fa3e..65953b31a224 100644
--- a/packages/vitest/src/node/reporters/tap.ts
+++ b/packages/vitest/src/node/reporters/tap.ts
@@ -1,7 +1,7 @@
import type { Task } from '@vitest/runner'
import type { ErrorWithDiff, ParsedStack } from '@vitest/utils'
-import type { Vitest } from '../../node'
-import type { Reporter } from '../../types/reporter'
+import type { Vitest } from '../core'
+import type { Reporter } from '../types/reporter'
import { parseErrorStacktrace } from '../../utils/source-map'
import { IndentedLogger } from './renderers/indented-logger'
diff --git a/packages/vitest/src/node/reporters/utils.ts b/packages/vitest/src/node/reporters/utils.ts
index 7cc88b60f074..e3306fa0e36a 100644
--- a/packages/vitest/src/node/reporters/utils.ts
+++ b/packages/vitest/src/node/reporters/utils.ts
@@ -1,7 +1,9 @@
import type { ViteNodeRunner } from 'vite-node/client'
-import type { Reporter, ResolvedConfig, Vitest } from '../../types'
-import { BenchmarkReportsMap, ReportersMap } from './index'
+import type { Reporter } from '../types/reporter'
+import type { ResolvedConfig } from '../types/config'
+import type { Vitest } from '../core'
import type { BenchmarkBuiltinReporters, BuiltinReporters } from './index'
+import { BenchmarkReportsMap, ReportersMap } from './index'
async function loadCustomReporterModule(
path: string,
diff --git a/packages/vitest/src/node/reporters/verbose.ts b/packages/vitest/src/node/reporters/verbose.ts
index 33b417511141..9f97221c4241 100644
--- a/packages/vitest/src/node/reporters/verbose.ts
+++ b/packages/vitest/src/node/reporters/verbose.ts
@@ -1,5 +1,5 @@
import c from 'tinyrainbow'
-import type { TaskResultPack } from '../../types'
+import type { TaskResultPack } from '@vitest/runner'
import { getFullName } from '../../utils'
import { F_RIGHT } from '../../utils/figures'
import { DefaultReporter } from './default'
diff --git a/packages/vitest/src/node/sequencers/types.ts b/packages/vitest/src/node/sequencers/types.ts
index fd5237f350b5..5e10b2c00a24 100644
--- a/packages/vitest/src/node/sequencers/types.ts
+++ b/packages/vitest/src/node/sequencers/types.ts
@@ -1,4 +1,4 @@
-import type { Awaitable } from '../../types'
+import type { Awaitable } from '../../types/general'
import type { Vitest } from '../core'
import type { WorkspaceSpec } from '../pool'
diff --git a/packages/vitest/src/types/benchmark.ts b/packages/vitest/src/node/types/benchmark.ts
similarity index 57%
rename from packages/vitest/src/types/benchmark.ts
rename to packages/vitest/src/node/types/benchmark.ts
index 580c1ccfd4ff..e2ee6c53a884 100644
--- a/packages/vitest/src/types/benchmark.ts
+++ b/packages/vitest/src/node/types/benchmark.ts
@@ -1,14 +1,6 @@
-import type { Custom } from '@vitest/runner'
-import type { ChainableFunction } from '@vitest/runner/utils'
import type { Arrayable } from '@vitest/utils'
-import type {
- Bench as BenchFactory,
- Options as BenchOptions,
- Task as BenchTask,
- TaskResult as BenchTaskResult,
- TaskResult as TinybenchResult,
-} from 'tinybench'
-import type { BenchmarkBuiltinReporters } from '../node/reporters'
+
+import type { BenchmarkBuiltinReporters } from '../reporters'
import type { Reporter } from './reporter'
export interface BenchmarkUserOptions {
@@ -59,27 +51,3 @@ export interface BenchmarkUserOptions {
*/
outputJson?: string
}
-
-export interface Benchmark extends Custom {
- meta: {
- benchmark: true
- result?: BenchTaskResult
- }
-}
-
-export interface BenchmarkResult extends TinybenchResult {
- name: string
- rank: number
-}
-
-export type BenchFunction = (this: BenchFactory) => Promise | void
-type ChainableBenchmarkAPI = ChainableFunction<
- 'skip' | 'only' | 'todo',
- (name: string | Function, fn?: BenchFunction, options?: BenchOptions) => void
->
-export type BenchmarkAPI = ChainableBenchmarkAPI & {
- skipIf: (condition: any) => ChainableBenchmarkAPI
- runIf: (condition: any) => ChainableBenchmarkAPI
-}
-
-export { BenchTaskResult, BenchOptions, BenchFactory, BenchTask }
diff --git a/packages/vitest/src/types/browser.ts b/packages/vitest/src/node/types/browser.ts
similarity index 99%
rename from packages/vitest/src/types/browser.ts
rename to packages/vitest/src/node/types/browser.ts
index 853c2ead6867..2c88a74d56a6 100644
--- a/packages/vitest/src/types/browser.ts
+++ b/packages/vitest/src/node/types/browser.ts
@@ -2,7 +2,7 @@ import type { Awaitable, ErrorWithDiff, ParsedStack } from '@vitest/utils'
import type { ViteDevServer } from 'vite'
import type { CancelReason } from '@vitest/runner'
import type { StackTraceParserOptions } from '@vitest/utils/source-map'
-import type { WorkspaceProject } from '../node/workspace'
+import type { WorkspaceProject } from '../workspace'
import type { ApiConfig } from './config'
export interface BrowserProviderInitializationOptions {
diff --git a/packages/vitest/src/types/config.ts b/packages/vitest/src/node/types/config.ts
similarity index 96%
rename from packages/vitest/src/types/config.ts
rename to packages/vitest/src/node/types/config.ts
index 47f913df1692..0d87a4c87805 100644
--- a/packages/vitest/src/types/config.ts
+++ b/packages/vitest/src/node/types/config.ts
@@ -3,25 +3,29 @@ import type { PrettyFormatOptions } from '@vitest/pretty-format'
import type { FakeTimerInstallOpts } from '@sinonjs/fake-timers'
import type { SequenceHooks, SequenceSetupFiles } from '@vitest/runner'
import type { ViteNodeServerOptions } from 'vite-node'
+import type { SnapshotStateOptions } from '@vitest/snapshot'
import type {
BuiltinReporterOptions,
BuiltinReporters,
-} from '../node/reporters'
-import type { TestSequencerConstructor } from '../node/sequencers/types'
-import type { ChaiConfig } from '../integrations/chai/config'
+} from '../reporters'
+import type { TestSequencerConstructor } from '../sequencers/types'
+import type { ChaiConfig } from '../../integrations/chai/config'
+import type { Arrayable, ParsedStack } from '../../types/general'
+import type { JSDOMOptions } from '../../types/jsdom-options'
+import type { HappyDOMOptions } from '../../types/happy-dom-options'
+import type { EnvironmentOptions } from '../../types/environment'
import type { CoverageOptions, ResolvedCoverageOptions } from './coverage'
-import type { JSDOMOptions } from './jsdom-options'
-import type { HappyDOMOptions } from './happy-dom-options'
+import type { Pool, PoolOptions, ResolvedPoolOptions } from './pool-options'
+import type { BrowserConfigOptions, ResolvedBrowserOptions } from './browser'
import type { Reporter } from './reporter'
-import type { SnapshotStateOptions } from './snapshot'
-import type { Arrayable, ParsedStack } from './general'
import type { BenchmarkUserOptions } from './benchmark'
-import type { BrowserConfigOptions, ResolvedBrowserOptions } from './browser'
-import type { Pool, PoolOptions, ResolvedPoolOptions } from './pool-options'
+export type { CoverageOptions, ResolvedCoverageOptions }
+export type { BenchmarkUserOptions }
+export type { CoverageV8Options, CoverageIstanbulOptions } from './coverage'
export type { BrowserScript, BrowserConfigOptions } from './browser'
export type { SequenceHooks, SequenceSetupFiles } from '@vitest/runner'
-export type { SerializedConfig, RuntimeConfig } from '../runtime/config'
+export type { SerializedConfig, RuntimeConfig } from '../../runtime/config'
export type BuiltinEnvironment =
| 'node'
@@ -40,16 +44,7 @@ export type ApiConfig = Pick<
'port' | 'strictPort' | 'host' | 'middlewareMode'
>
-export type { JSDOMOptions, HappyDOMOptions }
-
-export interface EnvironmentOptions {
- /**
- * jsdom options.
- */
- jsdom?: JSDOMOptions
- happyDOM?: HappyDOMOptions
- [x: string]: unknown
-}
+export type { JSDOMOptions, HappyDOMOptions, EnvironmentOptions }
export type VitestRunMode = 'test' | 'benchmark'
@@ -1070,4 +1065,4 @@ export type ProjectConfig = Omit<
}
}
-export type { UserWorkspaceConfig } from '../config'
+export type { UserWorkspaceConfig } from '../../config'
diff --git a/packages/vitest/src/types/coverage.ts b/packages/vitest/src/node/types/coverage.ts
similarity index 95%
rename from packages/vitest/src/types/coverage.ts
rename to packages/vitest/src/node/types/coverage.ts
index 9bc381515b36..d61e0715e2ec 100644
--- a/packages/vitest/src/types/coverage.ts
+++ b/packages/vitest/src/node/types/coverage.ts
@@ -1,8 +1,7 @@
import type { TransformResult as ViteTransformResult } from 'vite'
import type { ReportOptions } from 'istanbul-reports'
-import type { Vitest } from '../node'
-import type { Arrayable } from './general'
-import type { AfterSuiteRunMeta } from './worker'
+import type { AfterSuiteRunMeta, Arrayable } from '../../types/general'
+import type { Vitest } from '../core'
type TransformResult =
| string
@@ -87,9 +86,9 @@ type CoverageReporterWithOptions<
: [ReporterName, Partial]
: [ReporterName, Record]
-type Provider = 'v8' | 'istanbul' | 'custom' | undefined
+export type CoverageProviderName = 'v8' | 'istanbul' | 'custom' | undefined
-export type CoverageOptions =
+export type CoverageOptions =
T extends 'istanbul'
? { provider: T } & CoverageIstanbulOptions
: T extends 'v8' ? {
@@ -116,7 +115,7 @@ type FieldsWithDefaultValues =
| 'allowExternal'
| 'processingConcurrency'
-export type ResolvedCoverageOptions =
+export type ResolvedCoverageOptions =
CoverageOptions &
Required, FieldsWithDefaultValues>> & { // Resolved fields which may have different typings as public configuration API has
reporter: CoverageReporterWithOptions[]
diff --git a/packages/vitest/src/types/pool-options.ts b/packages/vitest/src/node/types/pool-options.ts
similarity index 100%
rename from packages/vitest/src/types/pool-options.ts
rename to packages/vitest/src/node/types/pool-options.ts
diff --git a/packages/vitest/src/types/reporter.ts b/packages/vitest/src/node/types/reporter.ts
similarity index 66%
rename from packages/vitest/src/types/reporter.ts
rename to packages/vitest/src/node/types/reporter.ts
index 968eb85da159..975a86eafe1d 100644
--- a/packages/vitest/src/types/reporter.ts
+++ b/packages/vitest/src/node/types/reporter.ts
@@ -1,11 +1,12 @@
-import type { Vitest } from '../node'
-import type { Awaitable, UserConsoleLog } from './general'
-import type { File, TaskResultPack } from './tasks'
+import type { File, TaskResultPack } from '@vitest/runner'
+import type { Vitest } from '../core'
+import type { SerializedSpec } from '../../runtime/types/utils'
+import type { Awaitable, UserConsoleLog } from '../../types/general'
export interface Reporter {
onInit?: (ctx: Vitest) => void
onPathsCollected?: (paths?: string[]) => Awaitable
- onSpecsCollected?: (specs?: SerializableSpec[]) => Awaitable
+ onSpecsCollected?: (specs?: SerializedSpec[]) => Awaitable
onCollected?: (files?: File[]) => Awaitable
onFinished?: (
files: File[],
@@ -13,20 +14,10 @@ export interface Reporter {
coverage?: unknown
) => Awaitable
onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable
-
onTestRemoved?: (trigger?: string) => Awaitable
onWatcherStart?: (files?: File[], errors?: unknown[]) => Awaitable
onWatcherRerun?: (files: string[], trigger?: string) => Awaitable
-
onServerRestart?: (reason?: string) => Awaitable
-
onUserConsoleLog?: (log: UserConsoleLog) => Awaitable
-
onProcessTimeout?: () => Awaitable
}
-
-export type { Vitest }
-export type SerializableSpec = [
- project: { name: string | undefined; root: string },
- file: string,
-]
diff --git a/packages/vitest/src/types/vite.ts b/packages/vitest/src/node/types/vite.ts
similarity index 100%
rename from packages/vitest/src/types/vite.ts
rename to packages/vitest/src/node/types/vite.ts
diff --git a/packages/vitest/src/node/types/worker.ts b/packages/vitest/src/node/types/worker.ts
new file mode 100644
index 000000000000..e94d071caf81
--- /dev/null
+++ b/packages/vitest/src/node/types/worker.ts
@@ -0,0 +1,6 @@
+import type { MessagePort } from 'node:worker_threads'
+import type { ContextRPC } from '../../types/worker'
+
+export interface WorkerContext extends ContextRPC {
+ port: MessagePort
+}
diff --git a/packages/vitest/src/node/workspace.ts b/packages/vitest/src/node/workspace.ts
index f004ed187810..749f8a8a069f 100644
--- a/packages/vitest/src/node/workspace.ts
+++ b/packages/vitest/src/node/workspace.ts
@@ -18,19 +18,16 @@ import type {
} from 'vite'
import { ViteNodeRunner } from 'vite-node/client'
import { ViteNodeServer } from 'vite-node/server'
-import type {
- ProvidedContext,
- Vitest,
-} from '../types'
+import type { Typechecker } from '../typecheck/typechecker'
+import { deepMerge, nanoid } from '../utils/base'
+import { setup } from '../api/setup'
+import type { ProvidedContext } from '../types/general'
import type {
ResolvedConfig,
UserConfig,
UserWorkspaceConfig,
-} from '../types/config'
-import type { Typechecker } from '../typecheck/typechecker'
-import { deepMerge, nanoid } from '../utils/base'
-import { setup } from '../api/setup'
-import type { BrowserServer } from '../types/browser'
+} from './types/config'
+import type { BrowserServer } from './types/browser'
import { isBrowserEnabled, resolveConfig } from './config/resolveConfig'
import { WorkspaceVitestPlugin } from './plugins/workspace'
import { createViteServer } from './vite'
@@ -39,6 +36,7 @@ import { loadGlobalSetupFiles } from './globalSetup'
import { MocksPlugins } from './plugins/mocks'
import { CoverageTransform } from './plugins/coverageTransform'
import { serializeConfig } from './config/serializeConfig'
+import type { Vitest } from './core'
interface InitializeProjectOptions extends UserWorkspaceConfig {
workspaceConfigPath: string
diff --git a/packages/vitest/src/public/environments.ts b/packages/vitest/src/public/environments.ts
new file mode 100644
index 000000000000..52d9a0e0c4f3
--- /dev/null
+++ b/packages/vitest/src/public/environments.ts
@@ -0,0 +1,7 @@
+export { environments as builtinEnvironments } from '../integrations/env/index'
+export { populateGlobal } from '../integrations/env/utils'
+export type {
+ EnvironmentReturn,
+ VmEnvironmentReturn,
+ Environment,
+} from '../types/environment'
diff --git a/packages/vitest/src/public/index.ts b/packages/vitest/src/public/index.ts
new file mode 100644
index 000000000000..33f17ad0e200
--- /dev/null
+++ b/packages/vitest/src/public/index.ts
@@ -0,0 +1,334 @@
+// TODO: deprecate in favor of ``
+import '../node/types/vite'
+import '../types/global'
+
+import type {
+ CollectLineNumbers as CollectLineNumbers_,
+ CollectLines as CollectLines_,
+ Context as Context_,
+ RawErrsMap as RawErrsMap_,
+ RootAndTarget as RootAndTarget_,
+ TscErrorInfo as TscErrorInfo_,
+} from '../typecheck/types'
+
+import type {
+ ArgumentsType as ArgumentsType_,
+ Arrayable as Arrayable_,
+ Awaitable as Awaitable_,
+ Constructable as Constructable_,
+ MutableArray as MutableArray_,
+ Nullable as Nullable_,
+ OnServerRestartHandler as OnServerRestartHandler_,
+} from '../types/general'
+
+import type {
+ EnvironmentReturn as EnvironmentReturn_,
+ Environment as Environment_,
+ ResolvedTestEnvironment as ResolvedTestEnvironment_,
+ VmEnvironmentReturn as VmEnvironmentReturn_,
+} from '../types/environment'
+
+import type {
+ BaseCoverageOptions as BaseCoverageOptions_,
+ CoverageIstanbulOptions as CoverageIstanbulOptions_,
+ CoverageOptions as CoverageOptions_,
+ CoverageProviderModule as CoverageProviderModule_,
+ CoverageProviderName,
+ CoverageProvider as CoverageProvider_,
+ CoverageReporter as CoverageReporter_,
+ CoverageV8Options as CoverageV8Options_,
+ CustomProviderOptions as CustomProviderOptions_,
+ ReportContext as ReportContext_,
+ ResolvedCoverageOptions as ResolvedCoverageOptions_,
+} from '../node/types/coverage'
+
+import type {
+ /** @deprecated import from `vitest/node` instead */
+ Reporter as Reporter_,
+} from '../node/types/reporter'
+import type {
+ /** @deprecated import from `vitest/node` instead */
+ Vitest as Vitest_,
+} from '../node/core'
+import type {
+ ApiConfig as ApiConfig_,
+ BrowserConfigOptions as BrowserConfigOptions_,
+ BrowserScript as BrowserScript_,
+ BuiltinEnvironment as BuiltinEnvironment_,
+ CSSModuleScopeStrategy as CSSModuleScopeStrategy_,
+ DepsOptimizationOptions as DepsOptimizationOptions_,
+ EnvironmentOptions as EnvironmentOptions_,
+ HappyDOMOptions as HappyDOMOptions_,
+ InlineConfig as InlineConfig_,
+ JSDOMOptions as JSDOMOptions_,
+ PoolOptions as PoolOptions_,
+ Pool as Pool_,
+ ProjectConfig as ProjectConfig_,
+ ResolvedConfig as ResolvedConfig_,
+ SequenceHooks as SequenceHooks_,
+ SequenceSetupFiles as SequenceSetupFiles_,
+ TransformModePatterns as TransformModePatterns_,
+ TypecheckConfig as TypecheckConfig_,
+ UserConfig as UserConfig_,
+ UserWorkspaceConfig as UserWorkspaceConfig_,
+ VitestEnvironment as VitestEnvironment_,
+ VitestRunMode as VitestRunMode_,
+} from '../node/types/config'
+import type {
+ BenchmarkUserOptions as BenchmarkUserOptions_,
+} from '../node/types/benchmark'
+
+import type { SerializedSpec } from '../runtime/types/utils'
+
+export {
+ suite,
+ test,
+ describe,
+ it,
+ beforeAll,
+ beforeEach,
+ afterAll,
+ afterEach,
+ onTestFailed,
+ onTestFinished,
+} from '@vitest/runner'
+export { bench } from '../runtime/benchmark'
+export { expectTypeOf } from '../typecheck/expectTypeOf'
+export { assertType } from '../typecheck/assertType'
+
+export { runOnce, isFirstRun } from '../integrations/run-once'
+export { createExpect, assert, should, chai, expect } from '../integrations/chai'
+export { vi, vitest } from '../integrations/vi'
+export { getRunningMode, isWatchMode } from '../integrations/utils'
+export { inject } from '../integrations/inject'
+
+export type { VitestUtils } from '../integrations/vi'
+
+export type { ExpectTypeOf } from '../typecheck/expectTypeOf'
+export type { AssertType } from '../typecheck/assertType'
+
+/** @deprecated import `TypeCheckRawErrorsMap` from `vitest/node` instead */
+export type RawErrsMap = RawErrsMap_
+/** @deprecated import `TypeCheckErrorInfo` from `vitest/node` instead */
+export type TscErrorInfo = TscErrorInfo_
+/** @deprecated import `TypeCheckCollectLineNumbers` from `vitest/node` instead */
+export type CollectLineNumbers = CollectLineNumbers_
+/** @deprecated import `TypeCheckCollectLines` from `vitest/node` instead */
+export type CollectLines = CollectLines_
+/** @deprecated import `TypeCheckRootAndTarget` from `vitest/node` instead */
+export type RootAndTarget = RootAndTarget_
+/** @deprecated import `TypeCheckContext` from `vitest/node` instead */
+export type Context = Context_
+
+export type {
+ RunMode,
+ TaskState,
+ TaskBase,
+ TaskResult,
+ TaskResultPack,
+ Suite,
+ File,
+ Test,
+ Task,
+ DoneCallback,
+ TestFunction,
+ TestOptions,
+ TestAPI,
+ SuiteAPI,
+ HookListener,
+ HookCleanupCallback,
+ SuiteHooks,
+ SuiteCollector,
+ SuiteFactory,
+ RuntimeContext,
+ TestContext,
+ TaskContext,
+ ExtendedContext,
+ Custom,
+ TaskCustomOptions,
+ OnTestFailedHandler,
+ TaskMeta,
+} from '@vitest/runner'
+export type {
+ RuntimeRPC,
+ RunnerRPC,
+} from '../types/rpc'
+export type {
+ SnapshotData,
+ SnapshotUpdateState,
+ SnapshotStateOptions,
+ SnapshotMatchOptions,
+ SnapshotResult,
+ UncheckedSnapshot,
+ SnapshotSummary,
+ SnapshotSerializer,
+} from '@vitest/snapshot'
+
+export type {
+ ResolveIdFunction,
+ WorkerRPC,
+ WorkerGlobalState,
+ ContextTestEnvironment,
+ ContextRPC,
+} from '../types/worker'
+export type {
+ /** @deprecated import from `vitest/node` instead */
+ WorkerContext,
+} from '../node/types/worker'
+
+/** @deprecated do not use, internal helper */
+export type Awaitable = Awaitable_
+/** @deprecated do not use, internal helper */
+export type Nullable = Nullable_
+/** @deprecated do not use, internal helper */
+export type Arrayable = Arrayable_
+/** @deprecated do not use, internal helper */
+export type ArgumentsType = ArgumentsType_
+/** @deprecated do not use, internal helper */
+export type MutableArray = MutableArray_
+/** @deprecated do not use, internal helper */
+export type Constructable = Constructable_
+/** @deprecated import from `vitest/node` instead */
+export type OnServerRestartHandler = OnServerRestartHandler_
+
+export type {
+ ErrorWithDiff,
+ ParsedStack,
+ ModuleCache,
+ UserConsoleLog,
+ ModuleGraphData,
+ ProvidedContext,
+ AfterSuiteRunMeta,
+} from '../types/general'
+
+/** @deprecated import from `vitest/environments` instead */
+export type EnvironmentReturn = EnvironmentReturn_
+/** @deprecated import from `vitest/environments` instead */
+export type VmEnvironmentReturn = VmEnvironmentReturn_
+/** @deprecated import from `vitest/environments` instead */
+export type Environment = Environment_
+/** @deprecated do not use it */
+export type ResolvedTestEnvironment = ResolvedTestEnvironment_
+
+/** @deprecated import from `vitest/node` instead */
+export type CoverageProvider = CoverageProvider_
+/** @deprecated import from `vitest/node` instead */
+export type ReportContext = ReportContext_
+/** @deprecated import from `vitest/node` instead */
+export type CoverageProviderModule = CoverageProviderModule_
+/** @deprecated import from `vitest/node` instead */
+export type CoverageReporter = CoverageReporter_
+/** @deprecated import from `vitest/node` instead */
+export type CoverageOptions = CoverageOptions_
+/** @deprecated import from `vitest/node` instead */
+export type ResolvedCoverageOptions = ResolvedCoverageOptions_
+/** @deprecated import from `vitest/node` instead */
+export type BaseCoverageOptions = BaseCoverageOptions_
+/** @deprecated import from `vitest/node` instead */
+export type CoverageIstanbulOptions = CoverageIstanbulOptions_
+/** @deprecated import from `vitest/node` instead */
+export type CoverageV8Options = CoverageV8Options_
+/** @deprecated import from `vitest/node` instead */
+export type CustomProviderOptions = CustomProviderOptions_
+
+export type { CancelReason } from '@vitest/runner'
+export type { DiffOptions } from '@vitest/utils/diff'
+export type {
+ MockedFunction,
+ MockedObject,
+ MockInstance,
+ Mock,
+ MockContext,
+ Mocked,
+ MockedClass,
+} from '../integrations/spy'
+export type { BrowserUI } from '../types/ui'
+
+/** @deprecated import from `vitest/node` instead */
+export type Reporter = Reporter_
+/** @deprecated import from `vitest/node` instead */
+export type Vitest = Vitest_
+
+export type {
+ ExpectStatic,
+ AsymmetricMatchersContaining,
+ JestAssertion,
+ Assertion,
+ ExpectPollOptions,
+} from '@vitest/expect'
+
+export type {
+ SerializedConfig,
+ RuntimeConfig,
+ SerializedCoverageConfig,
+} from '../runtime/config'
+
+/** @deprecated import from `vitest/node` instead */
+export type BrowserScript = BrowserScript_
+/** @deprecated import from `vitest/node` instead */
+export type BrowserConfigOptions = BrowserConfigOptions_
+/** @deprecated import from `vitest/node` instead */
+export type SequenceHooks = SequenceHooks_
+/** @deprecated import from `vitest/node` instead */
+export type SequenceSetupFiles = SequenceSetupFiles_
+/** @deprecated import from `vitest/node` instead */
+export type BuiltinEnvironment = BuiltinEnvironment_
+/** @deprecated import from `vitest/node` instead */
+export type VitestEnvironment = VitestEnvironment_
+/** @deprecated import from `vitest/node` instead */
+export type Pool = Pool_
+/** @deprecated import from `vitest/node` instead */
+export type PoolOptions = PoolOptions_
+/** @deprecated import from `vitest/node` instead */
+export type CSSModuleScopeStrategy = CSSModuleScopeStrategy_
+/** @deprecated import from `vitest/node` instead */
+export type ApiConfig = ApiConfig_
+/** @deprecated import from `vitest/node` instead */
+export type JSDOMOptions = JSDOMOptions_
+/** @deprecated import from `vitest/node` instead */
+export type HappyDOMOptions = HappyDOMOptions_
+/** @deprecated import from `vitest/node` instead */
+export type EnvironmentOptions = EnvironmentOptions_
+/** @deprecated import from `vitest/node` instead */
+export type VitestRunMode = VitestRunMode_
+/** @deprecated import from `vitest/node` instead */
+export type DepsOptimizationOptions = DepsOptimizationOptions_
+/** @deprecated import from `vitest/node` instead */
+export type TransformModePatterns = TransformModePatterns_
+/** @deprecated import from `vitest/node` instead */
+export type InlineConfig = InlineConfig_
+/** @deprecated import from `vitest/node` instead */
+export type TypecheckConfig = TypecheckConfig_
+/** @deprecated import from `vitest/node` instead */
+export type UserConfig = UserConfig_
+/** @deprecated import from `vitest/node` instead */
+export type ResolvedConfig = ResolvedConfig_
+/** @deprecated import from `vitest/node` instead */
+export type ProjectConfig = ProjectConfig_
+/** @deprecated import from `vitest/node` instead */
+export type UserWorkspaceConfig = UserWorkspaceConfig_
+
+export type {
+ Benchmark,
+ BenchmarkResult,
+ BenchFunction,
+ BenchmarkAPI,
+ BenchTaskResult,
+ BenchOptions,
+ BenchFactory,
+ BenchTask,
+} from '../runtime/types/benchmark'
+
+/** @deprecated use `SerializedSpec` instead */
+export type SerializableSpec = SerializedSpec
+export type { SerializedSpec }
+
+/** @deprecated import from `vitest/node` instead */
+export type BenchmarkUserOptions = BenchmarkUserOptions_
+
+export type {
+ TransformResultWithSource,
+ WebSocketHandlers,
+ WebSocketEvents,
+ WebSocketRPC,
+} from '../api/types'
diff --git a/packages/vitest/src/public/node.ts b/packages/vitest/src/public/node.ts
new file mode 100644
index 000000000000..7373e0916550
--- /dev/null
+++ b/packages/vitest/src/public/node.ts
@@ -0,0 +1,101 @@
+export type { Vitest } from '../node/core'
+export type { WorkspaceProject } from '../node/workspace'
+export { createVitest } from '../node/create'
+export { VitestPlugin } from '../node/plugins'
+export { startVitest } from '../node/cli/cli-api'
+export { parseCLI } from '../node/cli/cac'
+export { registerConsoleShortcuts } from '../node/stdin'
+export type { GlobalSetupContext } from '../node/globalSetup'
+export type { WorkspaceSpec, ProcessPool } from '../node/pool'
+export { createMethodsRPC } from '../node/pools/rpc'
+export { getFilePoolName } from '../node/pool'
+export { VitestPackageInstaller } from '../node/packageInstaller'
+export { createDebugger } from '../utils/debugger'
+export { resolveFsAllow } from '../node/plugins/utils'
+export { resolveApiServerConfig, resolveConfig } from '../node/config/resolveConfig'
+
+export { GitNotFoundError, FilesNotFoundError as TestsNotFoundError } from '../node/errors'
+
+export { distDir, rootDir } from '../paths'
+
+export type {
+ TestSequencer,
+ TestSequencerConstructor,
+} from '../node/sequencers/types'
+export { BaseSequencer } from '../node/sequencers/BaseSequencer'
+
+export type {
+ BrowserProviderInitializationOptions,
+ BrowserProvider,
+ CDPSession,
+ BrowserProviderModule,
+ ResolvedBrowserOptions,
+ BrowserProviderOptions,
+ BrowserBuiltinProvider,
+ BrowserScript,
+ BrowserCommand,
+ BrowserCommandContext,
+ BrowserServer,
+ BrowserServerState,
+ BrowserServerStateContext,
+ BrowserOrchestrator,
+ BrowserConfigOptions,
+} from '../node/types/browser'
+export type { JsonOptions } from '../node/reporters/json'
+export type { JUnitOptions } from '../node/reporters/junit'
+export type { HTMLOptions } from '../node/reporters/html'
+
+export { isFileServingAllowed, createServer, parseAst, parseAstAsync } from 'vite'
+export type * as Vite from 'vite'
+
+export type {
+ SequenceHooks,
+ SequenceSetupFiles,
+ BuiltinEnvironment,
+ VitestEnvironment,
+ Pool,
+ PoolOptions,
+ CSSModuleScopeStrategy,
+ ApiConfig,
+ JSDOMOptions,
+ HappyDOMOptions,
+ EnvironmentOptions,
+ VitestRunMode,
+ DepsOptimizationOptions,
+ TransformModePatterns,
+ InlineConfig,
+ TypecheckConfig,
+ UserConfig,
+ ResolvedConfig,
+ ProjectConfig,
+ UserWorkspaceConfig,
+ RuntimeConfig,
+} from '../node/types/config'
+
+export type { BenchmarkUserOptions } from '../node/types/benchmark'
+
+export type {
+ RawErrsMap as TypeCheckRawErrorsMap,
+ TscErrorInfo as TypeCheckErrorInfo,
+ CollectLineNumbers as TypeCheckCollectLineNumbers,
+ CollectLines as TypeCheckCollectLines,
+ RootAndTarget as TypeCheckRootAndTarget,
+ Context as TypeCheckContext,
+} from '../typecheck/types'
+
+export type { OnServerRestartHandler } from '../types/general'
+
+export type {
+ CoverageProvider,
+ ReportContext,
+ CoverageProviderModule,
+ CoverageReporter,
+ CoverageOptions,
+ ResolvedCoverageOptions,
+ BaseCoverageOptions,
+ CoverageIstanbulOptions,
+ CoverageV8Options,
+ CustomProviderOptions,
+} from '../node/types/coverage'
+
+export type { WorkerContext } from '../node/types/worker'
diff --git a/packages/vitest/src/runtime/benchmark.ts b/packages/vitest/src/runtime/benchmark.ts
index a2bb2ae00cbc..b9bc0f1c22ce 100644
--- a/packages/vitest/src/runtime/benchmark.ts
+++ b/packages/vitest/src/runtime/benchmark.ts
@@ -2,8 +2,8 @@ import type { Custom } from '@vitest/runner'
import { getCurrentSuite } from '@vitest/runner'
import { createChainable } from '@vitest/runner/utils'
import { noop } from '@vitest/utils'
-import type { BenchFunction, BenchOptions, BenchmarkAPI } from '../types'
import { isRunningInBenchmark } from '../utils'
+import type { BenchFunction, BenchOptions, BenchmarkAPI } from './types/benchmark'
const benchFns = new WeakMap()
const benchOptsMap = new WeakMap()
diff --git a/packages/vitest/src/runtime/config.ts b/packages/vitest/src/runtime/config.ts
index 68fad48c6798..912b4bb271d8 100644
--- a/packages/vitest/src/runtime/config.ts
+++ b/packages/vitest/src/runtime/config.ts
@@ -2,7 +2,7 @@ import type { FakeTimerInstallOpts } from '@sinonjs/fake-timers'
import type { PrettyFormatOptions } from '@vitest/pretty-format'
import type { SequenceHooks, SequenceSetupFiles } from '@vitest/runner'
import type { SnapshotUpdateState } from '@vitest/snapshot'
-import type { SnapshotEnvironment } from '@vitest/snapshot/types'
+import type { SnapshotEnvironment } from '@vitest/snapshot/environment'
/**
* Config that tests have access to.
diff --git a/packages/vitest/src/runtime/console.ts b/packages/vitest/src/runtime/console.ts
index 376298ec5881..82be8c24fd71 100644
--- a/packages/vitest/src/runtime/console.ts
+++ b/packages/vitest/src/runtime/console.ts
@@ -5,7 +5,7 @@ import { getSafeTimers } from '@vitest/utils'
import c from 'tinyrainbow'
import { RealDate } from '../integrations/mock/date'
import { getWorkerState } from '../utils'
-import type { WorkerGlobalState } from '../types'
+import type { WorkerGlobalState } from '../types/worker'
export const UNKNOWN_TEST_ID = '__vitest__unknown_test__'
diff --git a/packages/vitest/src/runtime/execute.ts b/packages/vitest/src/runtime/execute.ts
index 1f2d73f2b4d2..441e659c42a3 100644
--- a/packages/vitest/src/runtime/execute.ts
+++ b/packages/vitest/src/runtime/execute.ts
@@ -14,7 +14,7 @@ import { normalize, relative } from 'pathe'
import { processError } from '@vitest/utils/error'
import { distDir } from '../paths'
import type { MockMap } from '../types/mocker'
-import type { WorkerGlobalState } from '../types'
+import type { WorkerGlobalState } from '../types/worker'
import { VitestMocker } from './mocker'
import type { ExternalModulesExecutor } from './external-executor'
diff --git a/packages/vitest/src/runtime/inspector.ts b/packages/vitest/src/runtime/inspector.ts
index f2530e5c896c..4beae34b10be 100644
--- a/packages/vitest/src/runtime/inspector.ts
+++ b/packages/vitest/src/runtime/inspector.ts
@@ -1,6 +1,6 @@
import { createRequire } from 'node:module'
import { pathToFileURL } from 'node:url'
-import type { ContextRPC } from '../types'
+import type { ContextRPC } from '../types/worker'
import type { SerializedConfig } from './config'
const __require = createRequire(import.meta.url)
diff --git a/packages/vitest/src/runtime/rpc.ts b/packages/vitest/src/runtime/rpc.ts
index ae05442070a7..b1eb8f26d3e1 100644
--- a/packages/vitest/src/runtime/rpc.ts
+++ b/packages/vitest/src/runtime/rpc.ts
@@ -2,9 +2,9 @@ import { getSafeTimers } from '@vitest/utils'
import type { CancelReason } from '@vitest/runner'
import { createBirpc } from 'birpc'
import type { BirpcOptions, BirpcReturn } from 'birpc'
-import { getWorkerState } from '../utils/global'
import type { RunnerRPC, RuntimeRPC } from '../types/rpc'
-import type { WorkerRPC } from '../types'
+import type { WorkerRPC } from '../types/worker'
+import { getWorkerState } from './utils'
const { get } = Reflect
diff --git a/packages/vitest/src/runtime/runBaseTests.ts b/packages/vitest/src/runtime/runBaseTests.ts
index 3c9f8a53c98c..17e04c0f6a06 100644
--- a/packages/vitest/src/runtime/runBaseTests.ts
+++ b/packages/vitest/src/runtime/runBaseTests.ts
@@ -1,6 +1,5 @@
import { performance } from 'node:perf_hooks'
import { collectTests, startTests } from '@vitest/runner'
-import type { ResolvedTestEnvironment } from '../types'
import { getWorkerState, resetModules } from '../utils'
import { vi } from '../integrations/vi'
import {
@@ -8,6 +7,7 @@ import {
stopCoverageInsideWorker,
} from '../integrations/coverage'
import { setupChaiConfig } from '../integrations/chai/config'
+import type { ResolvedTestEnvironment } from '../types/environment'
import type { SerializedConfig } from './config'
import { setupGlobalEnv, withEnv } from './setup-node'
import type { VitestExecutor } from './execute'
diff --git a/packages/vitest/src/runtime/runVmTests.ts b/packages/vitest/src/runtime/runVmTests.ts
index 82f17ee38465..cee571fbf33d 100644
--- a/packages/vitest/src/runtime/runVmTests.ts
+++ b/packages/vitest/src/runtime/runVmTests.ts
@@ -10,9 +10,9 @@ import {
startCoverageInsideWorker,
stopCoverageInsideWorker,
} from '../integrations/coverage'
-import { getWorkerState } from '../utils/global'
-import * as VitestIndex from '../index'
+import * as VitestIndex from '../public/index'
import { resolveSnapshotEnvironment } from '../integrations/snapshot/environments/resolveSnapshotEnvironment'
+import { getWorkerState } from './utils'
import type { VitestExecutor } from './execute'
import { resolveTestRunner } from './runners'
import { setupCommonEnv } from './setup-common'
diff --git a/packages/vitest/src/runtime/runners/benchmark.ts b/packages/vitest/src/runtime/runners/benchmark.ts
index b7f77dc5c265..cc6edb95c824 100644
--- a/packages/vitest/src/runtime/runners/benchmark.ts
+++ b/packages/vitest/src/runtime/runners/benchmark.ts
@@ -12,7 +12,7 @@ import type {
BenchTask,
Benchmark,
BenchmarkResult,
-} from '../../types/benchmark'
+} from '../types/benchmark'
import type { SerializedConfig } from '../config'
import type { VitestExecutor } from '../execute'
diff --git a/packages/vitest/src/runtime/runners/index.ts b/packages/vitest/src/runtime/runners/index.ts
index 7017e4dfd21c..803721a743d8 100644
--- a/packages/vitest/src/runtime/runners/index.ts
+++ b/packages/vitest/src/runtime/runners/index.ts
@@ -2,7 +2,7 @@ import type { VitestRunner, VitestRunnerConstructor } from '@vitest/runner'
import { resolve } from 'pathe'
import type { VitestExecutor } from '../execute'
import { distDir } from '../../paths'
-import { getWorkerState } from '../../utils/global'
+import { getWorkerState } from '../utils'
import { rpc } from '../rpc'
import { takeCoverageInsideWorker } from '../../integrations/coverage'
import { loadDiffConfig, loadSnapshotSerializers } from '../setup-common'
diff --git a/packages/vitest/src/runtime/setup-common.ts b/packages/vitest/src/runtime/setup-common.ts
index c3715e0bcacb..9cfddb9da2a9 100644
--- a/packages/vitest/src/runtime/setup-common.ts
+++ b/packages/vitest/src/runtime/setup-common.ts
@@ -1,8 +1,8 @@
import { setSafeTimers } from '@vitest/utils'
import { addSerializer } from '@vitest/snapshot'
import type { SnapshotSerializer } from '@vitest/snapshot'
+import type { DiffOptions } from '@vitest/expect'
import { resetRunOnceCounter } from '../integrations/run-once'
-import type { DiffOptions } from '../types/matcher-utils'
import type { VitestExecutor } from './execute'
import type { SerializedConfig } from './config'
diff --git a/packages/vitest/src/runtime/setup-node.ts b/packages/vitest/src/runtime/setup-node.ts
index cf8f5bcba6c6..b4bd65acaeee 100644
--- a/packages/vitest/src/runtime/setup-node.ts
+++ b/packages/vitest/src/runtime/setup-node.ts
@@ -3,14 +3,11 @@ import util from 'node:util'
import timers from 'node:timers'
import { installSourcemapsSupport } from 'vite-node/source-map'
import { KNOWN_ASSET_TYPES } from 'vite-node/constants'
-import type {
- EnvironmentOptions,
- ResolvedTestEnvironment,
-} from '../types'
import { getSafeTimers, getWorkerState } from '../utils'
-import * as VitestIndex from '../index'
+import * as VitestIndex from '../public/index'
import { expect } from '../integrations/chai'
import { resolveSnapshotEnvironment } from '../integrations/snapshot/environments/resolveSnapshotEnvironment'
+import type { ResolvedTestEnvironment } from '../types/environment'
import { setupCommonEnv } from './setup-common'
import type { VitestExecutor } from './execute'
import type { SerializedConfig } from './config'
@@ -90,7 +87,7 @@ export async function setupConsoleLogSpy() {
export async function withEnv(
{ environment }: ResolvedTestEnvironment,
- options: EnvironmentOptions,
+ options: Record,
fn: () => Promise,
) {
// @ts-expect-error untyped global
diff --git a/packages/vitest/src/runtime/types/benchmark.ts b/packages/vitest/src/runtime/types/benchmark.ts
new file mode 100644
index 000000000000..fb83535b3f56
--- /dev/null
+++ b/packages/vitest/src/runtime/types/benchmark.ts
@@ -0,0 +1,33 @@
+import type { Custom } from '@vitest/runner'
+import type { ChainableFunction } from '@vitest/runner/utils'
+import type {
+ Bench as BenchFactory,
+ Options as BenchOptions,
+ Task as BenchTask,
+ TaskResult as BenchTaskResult,
+ TaskResult as TinybenchResult,
+} from 'tinybench'
+
+export interface Benchmark extends Custom {
+ meta: {
+ benchmark: true
+ result?: BenchTaskResult
+ }
+}
+
+export interface BenchmarkResult extends TinybenchResult {
+ name: string
+ rank: number
+}
+
+export type BenchFunction = (this: BenchFactory) => Promise | void
+type ChainableBenchmarkAPI = ChainableFunction<
+ 'skip' | 'only' | 'todo',
+ (name: string | Function, fn?: BenchFunction, options?: BenchOptions) => void
+>
+export type BenchmarkAPI = ChainableBenchmarkAPI & {
+ skipIf: (condition: any) => ChainableBenchmarkAPI
+ runIf: (condition: any) => ChainableBenchmarkAPI
+}
+
+export { BenchTaskResult, BenchOptions, BenchFactory, BenchTask }
diff --git a/packages/vitest/src/runtime/types/utils.ts b/packages/vitest/src/runtime/types/utils.ts
new file mode 100644
index 000000000000..e65c04ce3382
--- /dev/null
+++ b/packages/vitest/src/runtime/types/utils.ts
@@ -0,0 +1,4 @@
+export type SerializedSpec = [
+ project: { name: string | undefined; root: string },
+ file: string,
+]
diff --git a/packages/vitest/src/utils/global.ts b/packages/vitest/src/runtime/utils.ts
similarity index 94%
rename from packages/vitest/src/utils/global.ts
rename to packages/vitest/src/runtime/utils.ts
index 5692a9cf6115..fd94dd4cbb05 100644
--- a/packages/vitest/src/utils/global.ts
+++ b/packages/vitest/src/runtime/utils.ts
@@ -1,4 +1,4 @@
-import type { WorkerGlobalState } from '../types'
+import type { WorkerGlobalState } from '../types/worker'
export function getWorkerState(): WorkerGlobalState {
// @ts-expect-error untyped global
diff --git a/packages/vitest/src/runtime/vm/vite-executor.ts b/packages/vitest/src/runtime/vm/vite-executor.ts
index 9f2b40b370ac..7c6bb5e98802 100644
--- a/packages/vitest/src/runtime/vm/vite-executor.ts
+++ b/packages/vitest/src/runtime/vm/vite-executor.ts
@@ -4,7 +4,7 @@ import { normalize } from 'pathe'
import { CSS_LANGS_RE, KNOWN_ASSET_RE } from 'vite-node/constants'
import { toArray } from 'vite-node/utils'
import type { RuntimeRPC } from '../../types/rpc'
-import type { WorkerGlobalState } from '../../types'
+import type { WorkerGlobalState } from '../../types/worker'
import type { EsmExecutor } from './esm-executor'
import { SyntheticModule } from './utils'
diff --git a/packages/vitest/src/runtime/worker.ts b/packages/vitest/src/runtime/worker.ts
index f55a5b8ad6c4..e8bc761acc11 100644
--- a/packages/vitest/src/runtime/worker.ts
+++ b/packages/vitest/src/runtime/worker.ts
@@ -1,9 +1,9 @@
import { pathToFileURL } from 'node:url'
import { workerId as poolId } from 'tinypool'
import { ModuleCacheMap } from 'vite-node/client'
-import type { ContextRPC } from '../types/rpc'
import { loadEnvironment } from '../integrations/env/loader'
import { isChildProcess, setProcessTitle } from '../utils/base'
+import type { ContextRPC } from '../types/worker'
import { setupInspect } from './inspector'
import { createRuntimeRpc, rpcDone } from './rpc'
import type { VitestWorker } from './workers/types'
diff --git a/packages/vitest/src/runtime/workers/base.ts b/packages/vitest/src/runtime/workers/base.ts
index 740f170eff23..6d3c3a14a1d7 100644
--- a/packages/vitest/src/runtime/workers/base.ts
+++ b/packages/vitest/src/runtime/workers/base.ts
@@ -1,6 +1,6 @@
import { ModuleCacheMap } from 'vite-node/client'
import type { WorkerGlobalState } from '../../types/worker'
-import { provideWorkerState } from '../../utils/global'
+import { provideWorkerState } from '../utils'
import type { ContextExecutorOptions, VitestExecutor } from '../execute'
import { getDefaultRequestStubs, startVitestExecutor } from '../execute'
import type { MockMap } from '../../types/mocker'
diff --git a/packages/vitest/src/runtime/workers/threads.ts b/packages/vitest/src/runtime/workers/threads.ts
index 77fb7eb96dd5..34ac89691523 100644
--- a/packages/vitest/src/runtime/workers/threads.ts
+++ b/packages/vitest/src/runtime/workers/threads.ts
@@ -1,5 +1,5 @@
-import type { ContextRPC } from '../../types/rpc'
-import type { WorkerContext, WorkerGlobalState } from '../../types/worker'
+import type { WorkerContext } from '../../node/types/worker'
+import type { ContextRPC, WorkerGlobalState } from '../../types/worker'
import { runBaseTests } from './base'
import type { VitestWorker } from './types'
import { createThreadsRpcOptions } from './utils'
diff --git a/packages/vitest/src/runtime/workers/types.ts b/packages/vitest/src/runtime/workers/types.ts
index 0cbdc515d70d..989a3e4687c9 100644
--- a/packages/vitest/src/runtime/workers/types.ts
+++ b/packages/vitest/src/runtime/workers/types.ts
@@ -1,7 +1,7 @@
import type { BirpcOptions } from 'birpc'
import type { Awaitable } from '@vitest/utils'
-import type { ContextRPC, RuntimeRPC } from '../../types/rpc'
-import type { WorkerGlobalState } from '../../types/worker'
+import type { RuntimeRPC } from '../../types/rpc'
+import type { ContextRPC, WorkerGlobalState } from '../../types/worker'
export type WorkerRpcOptions = Pick<
BirpcOptions,
diff --git a/packages/vitest/src/runtime/workers/utils.ts b/packages/vitest/src/runtime/workers/utils.ts
index 869faad47816..82b518c2b746 100644
--- a/packages/vitest/src/runtime/workers/utils.ts
+++ b/packages/vitest/src/runtime/workers/utils.ts
@@ -1,7 +1,7 @@
import type { TinypoolWorkerMessage } from 'tinypool'
import { parseRegexp } from '@vitest/utils'
-import type { WorkerContext } from '../../types/worker'
-import type { ResolvedConfig, SerializedConfig } from '../../types/config'
+import type { ResolvedConfig, SerializedConfig } from '../../node/types/config'
+import type { WorkerContext } from '../../node/types/worker'
import type { WorkerRpcOptions } from './types'
const REGEXP_WRAP_PREFIX = '$$vitest:'
diff --git a/packages/vitest/src/runtime/workers/vmThreads.ts b/packages/vitest/src/runtime/workers/vmThreads.ts
index 3197cd34ba1a..399717d6f57e 100644
--- a/packages/vitest/src/runtime/workers/vmThreads.ts
+++ b/packages/vitest/src/runtime/workers/vmThreads.ts
@@ -1,5 +1,5 @@
-import type { ContextRPC } from '../../types/rpc'
-import type { WorkerContext, WorkerGlobalState } from '../../types/worker'
+import type { WorkerContext } from '../../node/types/worker'
+import type { ContextRPC, WorkerGlobalState } from '../../types/worker'
import type { VitestWorker, WorkerRpcOptions } from './types'
import { createThreadsRpcOptions } from './utils'
import { runVmTests } from './vm'
diff --git a/packages/vitest/src/typecheck/collect.ts b/packages/vitest/src/typecheck/collect.ts
index eb4afacaae32..7c7aca0a48aa 100644
--- a/packages/vitest/src/typecheck/collect.ts
+++ b/packages/vitest/src/typecheck/collect.ts
@@ -9,7 +9,7 @@ import {
interpretTaskModes,
someTasksAreOnly,
} from '@vitest/runner/utils'
-import type { File, Suite, Test } from '../types'
+import type { File, Suite, Test } from '@vitest/runner'
import type { WorkspaceProject } from '../node/workspace'
interface ParsedFile extends File {
diff --git a/packages/vitest/src/typecheck/parse.ts b/packages/vitest/src/typecheck/parse.ts
index 0cd6fdbcfe12..0a014746618c 100644
--- a/packages/vitest/src/typecheck/parse.ts
+++ b/packages/vitest/src/typecheck/parse.ts
@@ -3,7 +3,7 @@ import os from 'node:os'
import { writeFile } from 'node:fs/promises'
import { basename, dirname, join, resolve } from 'pathe'
import { getTsconfig as getTsconfigContent } from 'get-tsconfig'
-import type { TypecheckConfig } from '../types'
+import type { TypecheckConfig } from '../node/types/config'
import type { RawErrsMap, TscErrorInfo } from './types'
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
diff --git a/packages/vitest/src/typecheck/typechecker.ts b/packages/vitest/src/typecheck/typechecker.ts
index b4bc264d38be..b50507aaee2d 100644
--- a/packages/vitest/src/typecheck/typechecker.ts
+++ b/packages/vitest/src/typecheck/typechecker.ts
@@ -5,22 +5,17 @@ import { execa } from 'execa'
import { basename, extname, resolve } from 'pathe'
import { TraceMap, generatedPositionFor } from '@vitest/utils/source-map'
import type { RawSourceMap } from '@ampproject/remapping'
+import type { ParsedStack } from '@vitest/utils'
+import type { File, Task, TaskResultPack, TaskState } from '@vitest/runner'
import { getTasks } from '../utils'
-import type {
- Awaitable,
- File,
- ParsedStack,
- Task,
- TaskResultPack,
- TaskState,
- TscErrorInfo,
- Vitest,
-} from '../types'
import type { WorkspaceProject } from '../node/workspace'
+import type { Awaitable } from '../types/general'
+import type { Vitest } from '../node/core'
import { getRawErrsMapFromTsCompile, getTsconfig } from './parse'
import { createIndexMap } from './utils'
import type { FileInformation } from './collect'
import { collectTests } from './collect'
+import type { TscErrorInfo } from './types'
export class TypeCheckError extends Error {
name = 'TypeCheckError'
diff --git a/packages/vitest/src/types/chai.ts b/packages/vitest/src/types/chai.ts
deleted file mode 100644
index a922590e82b9..000000000000
--- a/packages/vitest/src/types/chai.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { MatcherState } from '@vitest/expect'
diff --git a/packages/vitest/src/types/environment.ts b/packages/vitest/src/types/environment.ts
new file mode 100644
index 000000000000..fb047822d149
--- /dev/null
+++ b/packages/vitest/src/types/environment.ts
@@ -0,0 +1,36 @@
+import type { Awaitable } from './general'
+import type { HappyDOMOptions } from './happy-dom-options'
+import type { JSDOMOptions } from './jsdom-options'
+
+export interface EnvironmentReturn {
+ teardown: (global: any) => Awaitable
+}
+
+export interface VmEnvironmentReturn {
+ getVmContext: () => { [key: string]: any }
+ teardown: () => Awaitable
+}
+
+export interface Environment {
+ name: string
+ transformMode: 'web' | 'ssr'
+ setupVM?: (options: Record) => Awaitable
+ setup: (
+ global: any,
+ options: Record
+ ) => Awaitable
+}
+
+export interface EnvironmentOptions {
+ /**
+ * jsdom options.
+ */
+ jsdom?: JSDOMOptions
+ happyDOM?: HappyDOMOptions
+ [x: string]: unknown
+}
+
+export interface ResolvedTestEnvironment {
+ environment: Environment
+ options: Record | null
+}
diff --git a/packages/vitest/src/types/general.ts b/packages/vitest/src/types/general.ts
index 79cab51e59b4..22f86a00fe04 100644
--- a/packages/vitest/src/types/general.ts
+++ b/packages/vitest/src/types/general.ts
@@ -13,29 +13,19 @@ export interface Constructable {
new (...args: any[]): any
}
+export type TransformMode = 'web' | 'ssr'
+
+/** @deprecated not used */
export interface ModuleCache {
promise?: Promise
exports?: any
code?: string
}
-export interface EnvironmentReturn {
- teardown: (global: any) => Awaitable
-}
-
-export interface VmEnvironmentReturn {
- getVmContext: () => { [key: string]: any }
- teardown: () => Awaitable
-}
-
-export interface Environment {
- name: string
- transformMode: 'web' | 'ssr'
- setupVM?: (options: Record) => Awaitable
- setup: (
- global: any,
- options: Record
- ) => Awaitable
+export interface AfterSuiteRunMeta {
+ coverage?: unknown
+ transformMode: TransformMode
+ projectName?: string
}
export interface UserConsoleLog {
diff --git a/packages/vitest/src/types/global.ts b/packages/vitest/src/types/global.ts
index 23158dada2b8..fda010d402d2 100644
--- a/packages/vitest/src/types/global.ts
+++ b/packages/vitest/src/types/global.ts
@@ -1,9 +1,9 @@
import type { Plugin as PrettyFormatPlugin } from '@vitest/pretty-format'
import type { SnapshotState } from '@vitest/snapshot'
import type { ExpectStatic, PromisifyAssertion, Tester } from '@vitest/expect'
+import type { VitestEnvironment } from '../node/types/config'
+import type { BenchmarkResult } from '../runtime/types/benchmark'
import type { UserConsoleLog } from './general'
-import type { VitestEnvironment } from './config'
-import type { BenchmarkResult } from './benchmark'
declare global {
// eslint-disable-next-line ts/no-namespace
diff --git a/packages/vitest/src/types/index.ts b/packages/vitest/src/types/index.ts
deleted file mode 100644
index 15380909c447..000000000000
--- a/packages/vitest/src/types/index.ts
+++ /dev/null
@@ -1,84 +0,0 @@
-import './vite'
-import './global'
-
-export { expectTypeOf, type ExpectTypeOf } from '../typecheck/expectTypeOf'
-export { assertType, type AssertType } from '../typecheck/assertType'
-export type * from '../typecheck/types'
-export type * from './tasks'
-export type * from './rpc'
-export type * from './reporter'
-export type * from './snapshot'
-export type * from './worker'
-export type * from './general'
-export type * from './coverage'
-export type * from './benchmark'
-export type { CancelReason } from '@vitest/runner'
-export type { DiffOptions } from '@vitest/utils/diff'
-export type {
- MockedFunction,
- MockedObject,
- MockInstance,
- Mock,
- MockContext,
- Mocked,
- MockedClass,
-} from '../integrations/spy'
-export type { BrowserUI } from './ui'
-
-export type {
- ExpectStatic,
- AsymmetricMatchersContaining,
- JestAssertion,
- Assertion,
- ExpectPollOptions,
-} from '@vitest/expect'
-
-export type {
- /** @deprecated import from `vitest/node` instead */
- BrowserScript,
- /** @deprecated import from `vitest/node` instead */
- BrowserConfigOptions,
- /** @deprecated import from `vitest/node` instead */
- SequenceHooks,
- /** @deprecated import from `vitest/node` instead */
- SequenceSetupFiles,
- /** @deprecated import from `vitest/node` instead */
- BuiltinEnvironment,
- /** @deprecated import from `vitest/node` instead */
- VitestEnvironment,
- /** @deprecated import from `vitest/node` instead */
- Pool,
- /** @deprecated import from `vitest/node` instead */
- PoolOptions,
- /** @deprecated import from `vitest/node` instead */
- CSSModuleScopeStrategy,
- /** @deprecated import from `vitest/node` instead */
- ApiConfig,
- /** @deprecated import from `vitest/node` instead */
- JSDOMOptions,
- /** @deprecated import from `vitest/node` instead */
- HappyDOMOptions,
- /** @deprecated import from `vitest/node` instead */
- EnvironmentOptions,
- /** @deprecated import from `vitest/node` instead */
- VitestRunMode,
- /** @deprecated import from `vitest/node` instead */
- DepsOptimizationOptions,
- /** @deprecated import from `vitest/node` instead */
- TransformModePatterns,
- /** @deprecated import from `vitest/node` instead */
- InlineConfig,
- /** @deprecated import from `vitest/node` instead */
- TypecheckConfig,
- /** @deprecated import from `vitest/node` instead */
- UserConfig,
- /** @deprecated import from `vitest/node` instead */
- ResolvedConfig,
- /** @deprecated import from `vitest/node` instead */
- ProjectConfig,
- /** @deprecated import from `vitest/node` instead */
- UserWorkspaceConfig,
-
- RuntimeConfig,
- SerializedConfig,
-} from './config'
diff --git a/packages/vitest/src/types/jsdom-options.ts b/packages/vitest/src/types/jsdom-options.ts
index 039965a97e76..6248812aa463 100644
--- a/packages/vitest/src/types/jsdom-options.ts
+++ b/packages/vitest/src/types/jsdom-options.ts
@@ -4,7 +4,7 @@ export interface JSDOMOptions {
*
* @default ''
*/
- html?: string | Buffer | ArrayBufferLike
+ html?: string | ArrayBufferLike
/**
* referrer just affects the value read from document.referrer.
* It defaults to no referrer (which reflects as the empty string).
@@ -75,5 +75,5 @@ export interface JSDOMOptions {
* @default false
*/
cookieJar?: boolean
- resources?: 'usable' | any
+ resources?: 'usable'
}
diff --git a/packages/vitest/src/types/loader.ts b/packages/vitest/src/types/loader.ts
deleted file mode 100644
index 325cc8f6fe04..000000000000
--- a/packages/vitest/src/types/loader.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-import type { Awaitable } from './general'
-
-interface ModuleContext extends Record {
- conditions: string[]
- parentURL?: string
-}
-
-export enum ModuleFormat {
- Builtin = 'builtin',
- Commonjs = 'commonjs',
- Json = 'json',
- Module = 'module',
- Wasm = 'wasm',
-}
-
-export interface ResolveResult {
- url: string
- shortCircuit?: boolean
- format?: ModuleFormat
-}
-
-export interface Resolver {
- (
- url: string,
- context: ModuleContext,
- next: Resolver
- ): Awaitable
-}
-
-interface LoaderContext extends Record {
- format: ModuleFormat
- importAssertions: Record
-}
-
-interface LoaderResult {
- format: ModuleFormat
- shortCircuit?: boolean
- source: string | ArrayBuffer | SharedArrayBuffer | Uint8Array
-}
-
-export interface Loader {
- (url: string, context: LoaderContext, next: Loader): Awaitable
-}
diff --git a/packages/vitest/src/types/matcher-utils.ts b/packages/vitest/src/types/matcher-utils.ts
deleted file mode 100644
index 2d52466af2f3..000000000000
--- a/packages/vitest/src/types/matcher-utils.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import type { Formatter } from 'tinyrainbow'
-
-export interface MatcherHintOptions {
- comment?: string
- expectedColor?: Formatter
- isDirectExpectCall?: boolean
- isNot?: boolean
- promise?: string
- receivedColor?: Formatter
- secondArgument?: string
- secondArgumentColor?: Formatter
-}
-
-export interface DiffOptions {
- aAnnotation?: string
- aColor?: Formatter
- aIndicator?: string
- bAnnotation?: string
- bColor?: Formatter
- bIndicator?: string
- changeColor?: Formatter
- changeLineTrailingSpaceColor?: Formatter
- commonColor?: Formatter
- commonIndicator?: string
- commonLineTrailingSpaceColor?: Formatter
- contextLines?: number
- emptyFirstOrLastLinePlaceholder?: string
- expand?: boolean
- includeChangeCounts?: boolean
- omitAnnotationLines?: boolean
- patchColor?: Formatter
- // pretty-format type
- compareKeys?: any
- truncateThreshold?: number
- truncateAnnotation?: string
- truncateAnnotationColor?: Formatter
-}
diff --git a/packages/vitest/src/types/rpc.ts b/packages/vitest/src/types/rpc.ts
index c240f8a0bcad..7f5cc4bc8380 100644
--- a/packages/vitest/src/types/rpc.ts
+++ b/packages/vitest/src/types/rpc.ts
@@ -1,31 +1,21 @@
import type { FetchResult, RawSourceMap, ViteNodeResolveId } from 'vite-node'
-import type { CancelReason } from '@vitest/runner'
-import type {
- EnvironmentOptions,
- Pool,
- SerializedConfig,
- VitestEnvironment,
-} from './config'
-import type { Environment, UserConsoleLog } from './general'
-import type { SnapshotResult } from './snapshot'
-import type { File, TaskResultPack } from './tasks'
-import type { AfterSuiteRunMeta } from './worker'
-
-type TransformMode = 'web' | 'ssr'
+import type { CancelReason, File, TaskResultPack } from '@vitest/runner'
+import type { SnapshotResult } from '@vitest/snapshot'
+import type { AfterSuiteRunMeta, TransformMode, UserConsoleLog } from './general'
export interface RuntimeRPC {
fetch: (
id: string,
- environment: TransformMode
+ transformMode: TransformMode
) => Promise<{
externalize?: string
id?: string
}>
- transform: (id: string, environment: TransformMode) => Promise
+ transform: (id: string, transformMode: TransformMode) => Promise
resolveId: (
id: string,
importer: string | undefined,
- environment: TransformMode
+ transformMode: TransformMode
) => Promise
getSourceMap: (
id: string,
@@ -49,26 +39,3 @@ export interface RuntimeRPC {
export interface RunnerRPC {
onCancel: (reason: CancelReason) => void
}
-
-export interface ContextTestEnvironment {
- name: VitestEnvironment
- transformMode?: TransformMode
- options: EnvironmentOptions | null
-}
-
-export interface ResolvedTestEnvironment {
- environment: Environment
- options: EnvironmentOptions | null
-}
-
-export interface ContextRPC {
- pool: Pool
- worker: string
- workerId: number
- config: SerializedConfig
- projectName: string
- files: string[]
- environment: ContextTestEnvironment
- providedContext: Record
- invalidates?: string[]
-}
diff --git a/packages/vitest/src/types/snapshot.ts b/packages/vitest/src/types/snapshot.ts
deleted file mode 100644
index 6d3e27ef5216..000000000000
--- a/packages/vitest/src/types/snapshot.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-export type {
- SnapshotData,
- SnapshotUpdateState,
- SnapshotStateOptions,
- SnapshotMatchOptions,
- SnapshotResult,
- UncheckedSnapshot,
- SnapshotSummary,
- SnapshotSerializer,
-} from '@vitest/snapshot'
diff --git a/packages/vitest/src/types/tasks.ts b/packages/vitest/src/types/tasks.ts
deleted file mode 100644
index 50f54043fb7b..000000000000
--- a/packages/vitest/src/types/tasks.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-export type {
- RunMode,
- TaskState,
- TaskBase,
- TaskResult,
- TaskResultPack,
- Suite,
- File,
- Test,
- Task,
- DoneCallback,
- TestFunction,
- TestOptions,
- TestAPI,
- SuiteAPI,
- HookListener,
- HookCleanupCallback,
- SuiteHooks,
- SuiteCollector,
- SuiteFactory,
- RuntimeContext,
- TestContext,
- TaskContext,
- ExtendedContext,
- Custom,
- TaskCustomOptions,
- OnTestFailedHandler,
- TaskMeta,
-} from '@vitest/runner'
diff --git a/packages/vitest/src/types/worker.ts b/packages/vitest/src/types/worker.ts
index f312fbae9294..78561f48c935 100644
--- a/packages/vitest/src/types/worker.ts
+++ b/packages/vitest/src/types/worker.ts
@@ -1,28 +1,37 @@
-import type { MessagePort } from 'node:worker_threads'
-import type { CancelReason, Task } from '@vitest/runner'
import type { ModuleCacheMap, ViteNodeResolveId } from 'vite-node'
import type { BirpcReturn } from 'birpc'
+import type { CancelReason, Task } from '@vitest/runner'
+import type { SerializedConfig } from '../runtime/config'
+import type { RunnerRPC, RuntimeRPC } from './rpc'
import type { MockMap } from './mocker'
-import type { SerializedConfig } from './config'
-import type { ContextRPC, RunnerRPC, RuntimeRPC } from './rpc'
-import type { Environment } from './general'
-
-export interface WorkerContext extends ContextRPC {
- port: MessagePort
-}
+import type { TransformMode } from './general'
+import type { Environment } from './environment'
+/** @deprecated unused */
export type ResolveIdFunction = (
id: string,
importer?: string
) => Promise
-export interface AfterSuiteRunMeta {
- coverage?: unknown
- transformMode: Environment['transformMode']
- projectName?: string
+export type WorkerRPC = BirpcReturn
+
+export interface ContextTestEnvironment {
+ name: string
+ transformMode?: TransformMode
+ options: Record | null
}
-export type WorkerRPC = BirpcReturn
+export interface ContextRPC {
+ pool: string
+ worker: string
+ workerId: number
+ config: SerializedConfig
+ projectName: string
+ files: string[]
+ environment: ContextTestEnvironment
+ providedContext: Record
+ invalidates?: string[]
+}
export interface WorkerGlobalState {
ctx: ContextRPC
diff --git a/packages/vitest/src/utils/config-helpers.ts b/packages/vitest/src/utils/config-helpers.ts
index e22f436d452b..8ab9a5065822 100644
--- a/packages/vitest/src/utils/config-helpers.ts
+++ b/packages/vitest/src/utils/config-helpers.ts
@@ -1,4 +1,4 @@
-import type { SerializedConfig } from '../types/config'
+import type { SerializedConfig } from '../node/types/config'
import type {
BenchmarkBuiltinReporters,
BuiltinReporters,
diff --git a/packages/vitest/src/utils/coverage.ts b/packages/vitest/src/utils/coverage.ts
index b8ac873f2d77..c2556e467312 100644
--- a/packages/vitest/src/utils/coverage.ts
+++ b/packages/vitest/src/utils/coverage.ts
@@ -1,7 +1,7 @@
import { relative } from 'pathe'
import mm from 'micromatch'
import type { CoverageMap } from 'istanbul-lib-coverage'
-import type { BaseCoverageOptions, ResolvedCoverageOptions } from '../types'
+import type { BaseCoverageOptions, ResolvedCoverageOptions } from '../node/types/coverage'
type Threshold = 'lines' | 'functions' | 'statements' | 'branches'
diff --git a/packages/vitest/src/utils/graph.ts b/packages/vitest/src/utils/graph.ts
index ee53d83b5baa..025b6bc47fc8 100644
--- a/packages/vitest/src/utils/graph.ts
+++ b/packages/vitest/src/utils/graph.ts
@@ -1,5 +1,6 @@
import type { ModuleNode } from 'vite'
-import type { ModuleGraphData, Vitest } from '../types'
+import type { Vitest } from '../node/core'
+import type { ModuleGraphData } from '../types/general'
export async function getModuleGraph(
ctx: Vitest,
diff --git a/packages/vitest/src/utils/index.ts b/packages/vitest/src/utils/index.ts
index bb46c6bdce5c..2a4a96d29416 100644
--- a/packages/vitest/src/utils/index.ts
+++ b/packages/vitest/src/utils/index.ts
@@ -4,7 +4,7 @@ import { getWorkerState } from '../utils'
export * from './graph'
export * from './tasks'
export * from './base'
-export * from './global'
+export * from '../runtime/utils'
export * from './timers'
export * from './env'
export * from './modules'
diff --git a/packages/vitest/src/utils/memory-limit.ts b/packages/vitest/src/utils/memory-limit.ts
index 28110c617e2a..cdd036aa1207 100644
--- a/packages/vitest/src/utils/memory-limit.ts
+++ b/packages/vitest/src/utils/memory-limit.ts
@@ -6,7 +6,7 @@
*/
import * as nodeos from 'node:os'
-import type { ResolvedConfig } from '../types/config'
+import type { ResolvedConfig } from '../node/types/config'
function getDefaultThreadsCount(config: ResolvedConfig) {
const numCpus
diff --git a/packages/vitest/src/utils/modules.ts b/packages/vitest/src/utils/modules.ts
index bad2ce1ab005..fc8e39017325 100644
--- a/packages/vitest/src/utils/modules.ts
+++ b/packages/vitest/src/utils/modules.ts
@@ -1,6 +1,6 @@
import type { ModuleCacheMap } from 'vite-node/client'
-import { getWorkerState } from './global'
+import { getWorkerState } from '../runtime/utils'
import { getSafeTimers } from './timers'
export function resetModules(modules: ModuleCacheMap, resetMocks = false) {
diff --git a/packages/vitest/src/utils/test-helpers.ts b/packages/vitest/src/utils/test-helpers.ts
index 1b37c5155887..dcfaef619e93 100644
--- a/packages/vitest/src/utils/test-helpers.ts
+++ b/packages/vitest/src/utils/test-helpers.ts
@@ -1,12 +1,8 @@
import { promises as fs } from 'node:fs'
import mm from 'micromatch'
-import type {
- ContextTestEnvironment,
- EnvironmentOptions,
- TransformModePatterns,
- VitestEnvironment,
-} from '../types'
import type { WorkspaceProject } from '../node/workspace'
+import type { EnvironmentOptions, TransformModePatterns, VitestEnvironment } from '../node/types/config'
+import type { ContextTestEnvironment } from '../types/worker'
import { groupBy } from './base'
export const envsOrder = ['node', 'jsdom', 'happy-dom', 'edge-runtime']
diff --git a/packages/vitest/src/workers.ts b/packages/vitest/src/workers.ts
index 5601196ce6f4..a138f0173e0e 100644
--- a/packages/vitest/src/workers.ts
+++ b/packages/vitest/src/workers.ts
@@ -3,7 +3,7 @@ export {
createThreadsRpcOptions,
unwrapSerializableConfig,
} from './runtime/workers/utils'
-export { provideWorkerState } from './utils/global'
+export { provideWorkerState } from './runtime/utils'
export { run as runVitestWorker, collect as collectVitestWorkerTests } from './runtime/worker'
export { runVmTests } from './runtime/workers/vm'
export { runBaseTests } from './runtime/workers/base'
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 0c72c8d0cc36..5eb8fc01f502 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -5,6 +5,7 @@ settings:
excludeLinksFromLockfile: false
overrides:
+ acorn: 8.11.3
mlly: ^1.7.1
rollup: ^4.19.0
vite: ^5.3.3
@@ -1437,18 +1438,12 @@ packages:
peerDependencies:
'@algolia/client-search': '>= 4.9.1 < 6'
algoliasearch: '>= 4.9.1 < 6'
- peerDependenciesMeta:
- '@algolia/client-search':
- optional: true
'@algolia/autocomplete-shared@1.9.3':
resolution: {integrity: sha512-Wnm9E4Ye6Rl6sTTqjoymD+l8DjSTHsHboVRYrKgEt8Q7UHm9nYbqhN/i0fhUYA3OAEH7WA8x3jfpnmJm3rKvaQ==}
peerDependencies:
'@algolia/client-search': '>= 4.9.1 < 6'
algoliasearch: '>= 4.9.1 < 6'
- peerDependenciesMeta:
- '@algolia/client-search':
- optional: true
'@algolia/cache-browser-local-storage@4.20.0':
resolution: {integrity: sha512-uujahcBt4DxduBTvYdwO3sBfHuJvJokiC3BP1+O70fglmE1ShkH8lpXqZBac1rrU3FnNYSUs4pL9lBdTKeRPOQ==}
@@ -4277,7 +4272,7 @@ packages:
acorn-jsx@5.3.2:
resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==}
peerDependencies:
- acorn: ^6.0.0 || ^7.0.0 || ^8.0.0
+ acorn: 8.11.3
acorn-walk@8.3.3:
resolution: {integrity: sha512-MxXdReSRhGO7VlFe1bRG/oI7/mdLV9B9JJT0N8vZOhF7gFRR5l3M8W9G8JxmKV+JC5mGqJ0QvqfSOLsCPa4nUw==}
@@ -4288,11 +4283,6 @@ packages:
engines: {node: '>=0.4.0'}
hasBin: true
- acorn@8.12.0:
- resolution: {integrity: sha512-RTvkC4w+KNXrM39/lWCUaG0IbRkWdCv7W/IOW9oU6SawyxulvkQy5HQPVTKxEjczcUvapcrw3cFx/60VN/NRNw==}
- engines: {node: '>=0.4.0'}
- hasBin: true
-
agent-base@7.1.0:
resolution: {integrity: sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==}
engines: {node: '>= 14'}
@@ -9253,15 +9243,13 @@ snapshots:
'@algolia/autocomplete-preset-algolia@1.9.3(@algolia/client-search@4.20.0)(algoliasearch@4.20.0)':
dependencies:
'@algolia/autocomplete-shared': 1.9.3(@algolia/client-search@4.20.0)(algoliasearch@4.20.0)
- algoliasearch: 4.20.0
- optionalDependencies:
'@algolia/client-search': 4.20.0
+ algoliasearch: 4.20.0
'@algolia/autocomplete-shared@1.9.3(@algolia/client-search@4.20.0)(algoliasearch@4.20.0)':
dependencies:
- algoliasearch: 4.20.0
- optionalDependencies:
'@algolia/client-search': 4.20.0
+ algoliasearch: 4.20.0
'@algolia/cache-browser-local-storage@4.20.0':
dependencies:
@@ -11338,7 +11326,7 @@ snapshots:
'@stylistic/eslint-plugin-js@2.6.0-beta.0(eslint@9.7.0)':
dependencies:
'@types/eslint': 8.56.10
- acorn: 8.12.0
+ acorn: 8.11.3(patch_hash=no36qihqjrd3chyjw73dk5xfkm)
eslint: 9.7.0
eslint-visitor-keys: 4.0.0
espree: 10.1.0
@@ -12625,9 +12613,9 @@ snapshots:
mime-types: 2.1.35
negotiator: 0.6.3
- acorn-jsx@5.3.2(acorn@8.12.0):
+ acorn-jsx@5.3.2(acorn@8.11.3(patch_hash=no36qihqjrd3chyjw73dk5xfkm)):
dependencies:
- acorn: 8.12.0
+ acorn: 8.11.3(patch_hash=no36qihqjrd3chyjw73dk5xfkm)
acorn-walk@8.3.3:
dependencies:
@@ -12635,8 +12623,6 @@ snapshots:
acorn@8.11.3(patch_hash=no36qihqjrd3chyjw73dk5xfkm): {}
- acorn@8.12.0: {}
-
agent-base@7.1.0:
dependencies:
debug: 4.3.5
@@ -14083,14 +14069,14 @@ snapshots:
espree@10.1.0:
dependencies:
- acorn: 8.12.0
- acorn-jsx: 5.3.2(acorn@8.12.0)
+ acorn: 8.11.3(patch_hash=no36qihqjrd3chyjw73dk5xfkm)
+ acorn-jsx: 5.3.2(acorn@8.11.3(patch_hash=no36qihqjrd3chyjw73dk5xfkm))
eslint-visitor-keys: 4.0.0
espree@9.6.1:
dependencies:
- acorn: 8.12.0
- acorn-jsx: 5.3.2(acorn@8.12.0)
+ acorn: 8.11.3(patch_hash=no36qihqjrd3chyjw73dk5xfkm)
+ acorn-jsx: 5.3.2(acorn@8.11.3(patch_hash=no36qihqjrd3chyjw73dk5xfkm))
eslint-visitor-keys: 3.4.3
esprima-extract-comments@1.1.0:
@@ -15276,7 +15262,7 @@ snapshots:
jsonc-eslint-parser@2.4.0:
dependencies:
- acorn: 8.12.0
+ acorn: 8.11.3(patch_hash=no36qihqjrd3chyjw73dk5xfkm)
eslint-visitor-keys: 3.4.3
espree: 9.6.1
semver: 7.6.2
@@ -15868,7 +15854,7 @@ snapshots:
mlly@1.7.1:
dependencies:
- acorn: 8.12.0
+ acorn: 8.11.3(patch_hash=no36qihqjrd3chyjw73dk5xfkm)
pathe: 1.1.2
pkg-types: 1.1.1
ufo: 1.5.3
@@ -17303,7 +17289,7 @@ snapshots:
terser@5.22.0:
dependencies:
'@jridgewell/source-map': 0.3.5
- acorn: 8.12.0
+ acorn: 8.11.3(patch_hash=no36qihqjrd3chyjw73dk5xfkm)
commander: 2.20.3
source-map-support: 0.5.21
@@ -17548,7 +17534,7 @@ snapshots:
unimport@3.7.2(rollup@4.19.0):
dependencies:
'@rollup/pluginutils': 5.1.0(rollup@4.19.0)
- acorn: 8.12.0
+ acorn: 8.11.3(patch_hash=no36qihqjrd3chyjw73dk5xfkm)
escape-string-regexp: 5.0.0
estree-walker: 3.0.3
fast-glob: 3.3.2
@@ -17676,14 +17662,14 @@ snapshots:
unplugin@1.11.0:
dependencies:
- acorn: 8.12.0
+ acorn: 8.11.3(patch_hash=no36qihqjrd3chyjw73dk5xfkm)
chokidar: 3.6.0
webpack-sources: 3.2.3
webpack-virtual-modules: 0.6.1
unplugin@1.7.1:
dependencies:
- acorn: 8.12.0
+ acorn: 8.11.3(patch_hash=no36qihqjrd3chyjw73dk5xfkm)
chokidar: 3.6.0
webpack-sources: 3.2.3
webpack-virtual-modules: 0.6.1
diff --git a/test/cli/test/console.test.ts b/test/cli/test/console.test.ts
index a1ead6cd8289..257a3bfb33e1 100644
--- a/test/cli/test/console.test.ts
+++ b/test/cli/test/console.test.ts
@@ -64,21 +64,11 @@ test('can run custom pools with Vitest', async () => {
expect(stackStderr).not.toMatch('❯ ')
if (process.platform !== 'win32') {
const root = resolve(process.cwd(), '../..')
- expect(stackStderr.replace(new RegExp(root, 'g'), '').replace(/\d+:\d+/g, 'ln:cl').replace(/\.\w+\.js:/g, '..js:')).toMatchInlineSnapshot(`
+ const trace = stackStderr.replace(new RegExp(root, 'g'), '').replace(/\d+:\d+/g, 'ln:cl').split('\n').slice(0, 3).join('\n')
+ expect(trace).toMatchInlineSnapshot(`
"stderr | trace.test.ts > logging to stdout
Trace: trace with trace
- at /test/cli/fixtures/console/trace.test.ts:ln:cl
- at file:///packages/runner/dist/index.js:ln:cl
- at file:///packages/runner/dist/index.js:ln:cl
- at runTest (file:///packages/runner/dist/index.js:ln:cl)
- at processTicksAndRejections (node:internal/process/task_queues:ln:cl)
- at runSuite (file:///packages/runner/dist/index.js:ln:cl)
- at runFiles (file:///packages/runner/dist/index.js:ln:cl)
- at startTests (file:///packages/runner/dist/index.js:ln:cl)
- at file:///packages/vitest/dist/chunks/runtime-runBaseTests..js:ln:cl
- at withEnv (file:///packages/vitest/dist/chunks/runtime-runBaseTests..js:ln:cl)
-
- "
+ at /test/cli/fixtures/console/trace.test.ts:ln:cl"
`)
}
})
diff --git a/test/reporters/src/context.ts b/test/reporters/src/context.ts
index e6703ebb18a2..5d43ca43bc6b 100644
--- a/test/reporters/src/context.ts
+++ b/test/reporters/src/context.ts
@@ -1,8 +1,9 @@
import type { ModuleGraph, ViteDevServer } from 'vite'
import type { Logger } from '../../../packages/vitest/src/node/logger'
-import type { Vitest } from '../../../packages/vitest/src/node'
+import type { Vitest } from '../../../packages/vitest/src/node/core'
+import type { File } from '../../../packages/vitest/src/public/index'
import type { StateManager } from '../../../packages/vitest/src/node/state'
-import type { File, ResolvedConfig } from '../../../packages/vitest/src/types'
+import type { ResolvedConfig } from '../../../packages/vitest/src/node/types/config'
interface Context {
vitest: Vitest
diff --git a/tsconfig.base.json b/tsconfig.base.json
index 7af1ddcf357e..88390ce2f49a 100644
--- a/tsconfig.base.json
+++ b/tsconfig.base.json
@@ -19,9 +19,9 @@
"@vitest/browser": ["./packages/browser/src/node/index.ts"],
"@vitest/browser/client": ["./packages/browser/src/client/client.ts"],
"~/*": ["./packages/ui/client/*"],
- "vitest": ["./packages/vitest/src/index.ts"],
+ "vitest": ["./packages/vitest/src/public/index.ts"],
"vitest/globals": ["./packages/vitest/globals.d.ts"],
- "vitest/node": ["./packages/vitest/src/node/index.ts"],
+ "vitest/node": ["./packages/vitest/src/public/node.ts"],
"vitest/execute": ["./packages/vitest/src/public/execute.ts"],
"vitest/config": ["./packages/vitest/src/config.ts"],
"vitest/coverage": ["./packages/vitest/src/coverage.ts"],