feat!: inline @vitest/runner package, do not publish it anymore (#10511)

This commit is contained in:
Vladimir
2026-06-03 15:25:44 +02:00
committed by GitHub
parent f6897bdc79
commit 1654928585
148 changed files with 905 additions and 1276 deletions
+1 -1
View File
@@ -95,7 +95,7 @@ export interface VitestRunner {
/**
* Publicly available configuration.
*/
config: VitestRunnerConfig
config: SerializedConfig
/**
* The name of the current pool. Can affect how stack trace is inferred on the server side.
*/
+1 -1
View File
@@ -27,7 +27,7 @@ This is a global [`ViteDevServer`](https://vite.dev/guide/api-javascript#vitedev
Public `state` is an experimental API (except `vitest.state.getReportedEntity`). Breaking changes might not follow SemVer, please pin Vitest's version when using it.
:::
Global state stores information about the current tests. It uses the same API from `@vitest/runner` by default, but we recommend using the [Reported Tasks API](/api/advanced/reporters#reported-tasks) instead by calling `state.getReportedEntity()` on the `@vitest/runner` API:
Global state stores information about the current tests. It uses internal serializable Task API by default, but we recommend using the [Reported Tasks API](/api/advanced/reporters#reported-tasks) instead by calling `state.getReportedEntity()`:
```ts
const task = vitest.state.idMap.get(taskId) // old API
-1
View File
@@ -92,7 +92,6 @@
"@types/node": "catalog:",
"@types/pngjs": "^6.0.5",
"@types/ws": "catalog:",
"@vitest/runner": "workspace:*",
"birpc": "catalog:",
"flatted": "catalog:",
"ivya": "^1.8.2",
+2 -1
View File
@@ -1,4 +1,5 @@
import type { CancelReason, FileSpecification } from '@vitest/runner'
import type { CancelReason } from 'vitest'
import type { FileSpecification } from 'vitest/internal/browser'
import type { OTELCarrier } from 'vitest/internal/traces'
import { getBrowserState } from './utils'
+1 -1
View File
@@ -1,6 +1,6 @@
import type { ModuleMocker } from '@vitest/mocker/browser'
import type { CancelReason } from '@vitest/runner'
import type { BirpcReturn } from 'birpc'
import type { CancelReason } from 'vitest'
import type { MarkOptions } from 'vitest/browser'
import type { WebSocketBrowserEvents, WebSocketBrowserHandlers } from '../types'
import type { IframeOrchestrator } from './orchestrator'
+3 -34
View File
@@ -1,10 +1,12 @@
import type { Context as OTELContext } from '@opentelemetry/api'
import type { GlobalChannelIncomingEvent, IframeChannelIncomingEvent, IframeChannelOutgoingEvent, IframeViewportDoneEvent, IframeViewportFailEvent } from '@vitest/browser/client'
import type { FileSpecification } from '@vitest/runner'
import type { BrowserTesterOptions, SerializedConfig } from 'vitest'
import type { FileSpecification } from 'vitest/internal/browser'
import { channel, client, globalChannel } from '@vitest/browser/client'
import { relative } from 'pathe'
import { Traces } from 'vitest/internal/traces'
// This needs to be tree shaken properly to not include the whole runner by accident
import { generateFileHash } from '../../../vitest/src/utils/tasks.js'
import { getUiAPI } from './ui'
import { getBrowserState, getConfig } from './utils'
@@ -481,39 +483,6 @@ function generateFileId(file: string) {
)
}
// TODO: copied from packages/runner/src/utils/collect.ts
interface HashMeta {
typecheck?: boolean
__vitest_label__?: string
}
function generateFileHash(
file: string,
projectName: string | undefined,
meta?: HashMeta,
): string {
const seed = [
file,
projectName || '',
meta?.typecheck ? '__typecheck__' : '',
meta?.__vitest_label__ || '',
].join('\0')
return generateHash(seed)
}
function generateHash(str: string): string {
let hash = 0
if (str.length === 0) {
return `${hash}`
}
for (let i = 0; i < str.length; i++) {
const char = str.charCodeAt(i)
hash = (hash << 5) - hash + char
hash = hash & hash // Convert to 32bit integer
}
return `${hash}`
}
async function setIframeViewport(
width: number,
height: number,
@@ -1,5 +1,4 @@
import type { VisualRegressionArtifact } from '@vitest/runner'
import type { AsyncMatcherResult, MatcherState } from 'vitest'
import type { AsyncMatcherResult, MatcherState, VisualRegressionArtifact } from 'vitest'
import type { BrowserPage, ScreenshotMatcherOptions } from '../../../../context'
import type { ScreenshotMatcherArguments, ScreenshotMatcherOutput } from '../../../shared/screenshotMatcher/types'
import type { Locator } from '../locators'
+12 -10
View File
@@ -1,21 +1,22 @@
import type {
CancelReason,
File,
Suite,
Task,
TaskEventPack,
TaskResultPack,
Test,
RunnerTestFile as File,
SerializedConfig,
RunnerTestSuite as Suite,
RunnerTask as Task,
RunnerTaskEventPack as TaskEventPack,
RunnerTaskResultPack as TaskResultPack,
RunnerTestCase as Test,
TestAnnotation,
TestArtifact,
TestExecutionMethod,
TestTryOptions,
VitestRunner,
} from '@vitest/runner'
import type { SerializedConfig, TestExecutionMethod, WorkerGlobalState } from 'vitest'
VitestTestRunner as VitestRunner,
WorkerGlobalState,
} from 'vitest'
import type { VitestBrowserClientMocker } from './mocker'
import type { CommandsManager } from './tester-utils'
import { globalChannel, onCancel } from '@vitest/browser/client'
import { getTestName } from '@vitest/runner/utils'
import { recordArtifact, TestRunner } from 'vitest'
import { page, userEvent } from 'vitest/browser'
import {
@@ -26,6 +27,7 @@ import {
takeCoverageInsideWorker,
} from 'vitest/internal/browser'
import { createStackString, parseStacktrace } from '../../../../utils/src/source-map'
import { getTestName } from '../../../../vitest/src/utils/tasks'
import { getBrowserState, getWorkerState, moduleRunner, now } from '../utils'
import { rpc } from './rpc'
import { VitestBrowserSnapshotEnvironment } from './snapshot'
+1 -1
View File
@@ -1,5 +1,5 @@
import type { BrowserRPC, IframeChannelEvent } from '@vitest/browser/client'
import type { FileSpecification } from '@vitest/runner'
import type { FileSpecification } from 'vitest/internal/browser'
import { channel, client, onCancel, registerPageMarkHandler } from '@vitest/browser/client'
import { parse } from 'flatted'
import { page, server, userEvent } from 'vitest/browser'
+1 -1
View File
@@ -1,4 +1,4 @@
import type { Task } from '@vitest/runner'
import type { RunnerTask as Task } from 'vitest'
import type { BrowserTraceEntryKind } from 'vitest/browser'
import type { BrowserRPC } from '../client'
import type { SerializedLocator } from './locators'
+2 -3
View File
@@ -1,6 +1,5 @@
import type { VitestRunner } from '@vitest/runner'
import type { Ivya } from 'ivya'
import type { SerializedConfig, WorkerGlobalState } from 'vitest'
import type { SerializedConfig, VitestTestRunner, WorkerGlobalState } from 'vitest'
import type { OTELCarrier, Traces } from 'vitest/internal/traces'
import type { IframeOrchestrator } from './orchestrator'
import type { CommandsManager } from './tester/tester-utils'
@@ -80,7 +79,7 @@ export interface BrowserRunnerState {
runningFiles: string[]
config: SerializedConfig
provider: string
runner: VitestRunner
runner: VitestTestRunner
viteConfig: {
root: string
}
-1
View File
@@ -219,7 +219,6 @@ export default (parentServer: ParentBrowserProject, base = '/'): Plugin[] => {
'@vitest/browser/client',
'@vitest/utils',
'@vitest/utils/source-map',
'@vitest/runner',
'@vitest/spy',
'@vitest/utils/error',
'std-env',
+4 -1
View File
@@ -1,13 +1,16 @@
import type { MockedModuleSerialized, ServerIdResolution, ServerMockResolution } from '@vitest/mocker'
import type { BaselineData, TaskEventPack, TaskResultPack, TestArtifact } from '@vitest/runner'
import type { BirpcReturn } from 'birpc'
import type {
AfterSuiteRunMeta,
BaselineData,
BrowserTesterOptions,
CancelReason,
RunnerTestFile,
SerializedTestSpecification,
SnapshotResult,
RunnerTaskEventPack as TaskEventPack,
RunnerTaskResultPack as TaskResultPack,
TestArtifact,
TestBenchmark,
TestExecutionMethod,
UserConsoleLog,
+1 -1
View File
@@ -1,6 +1,6 @@
# @vitest/expect
[![NPM version](https://img.shields.io/npm/v/@vitest/runner?color=a1b858&label=)](https://npmx.dev/package/@vitest/runner)
[![NPM version](https://img.shields.io/npm/v/@vitest/expect?color=a1b858&label=)](https://npmx.dev/package/@vitest/expect)
Jest's expect matchers as a Chai plugin.
-3
View File
@@ -46,8 +46,5 @@
"@vitest/utils": "workspace:*",
"chai": "catalog:",
"tinyrainbow": "catalog:"
},
"devDependencies": {
"@vitest/runner": "workspace:*"
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
import type { Test } from '@vitest/runner'
import type { MockInstance, MockResult, MockSettledResult } from '@vitest/spy'
import type { Constructable } from '@vitest/utils'
import type { Test } from '../../vitest/src/runtime/runner/types'
import type { AsymmetricMatcher } from './jest-asymmetric-matchers'
import type { Assertion, ChaiPlugin } from './types'
import { isMockFunction } from '@vitest/spy'
+1 -1
View File
@@ -1,4 +1,4 @@
import type { Test } from '@vitest/runner'
import type { Test } from '../../vitest/src/runtime/runner/types'
import type {
ChaiPlugin,
ExpectStatic,
+1 -1
View File
@@ -1,4 +1,4 @@
import type { Test } from '@vitest/runner/types'
import type { Test } from '../../vitest/src/runtime/runner/types'
import type { Assertion } from './types'
import { processError } from '@vitest/utils/error'
import { noop } from '@vitest/utils/helpers'
-7
View File
@@ -1,7 +0,0 @@
# @vitest/runner
[![NPM version](https://img.shields.io/npm/v/@vitest/runner?color=a1b858&label=)](https://npmx.dev/package/@vitest/runner)
Vitest mechanism to collect and run tests.
[GitHub](https://github.com/vitest-dev/vitest/tree/main/packages/runner) | [Documentation](https://vitest.dev/api/advanced/runner)
-54
View File
@@ -1,54 +0,0 @@
{
"name": "@vitest/runner",
"type": "module",
"version": "5.0.0-beta.4",
"description": "Vitest test runner",
"license": "MIT",
"funding": "https://opencollective.com/vitest",
"homepage": "https://vitest.dev/api/advanced/runner",
"repository": {
"type": "git",
"url": "git+https://github.com/vitest-dev/vitest.git",
"directory": "packages/runner"
},
"bugs": {
"url": "https://github.com/vitest-dev/vitest/issues"
},
"keywords": [
"vitest",
"test",
"test-runner"
],
"sideEffects": true,
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./utils": {
"types": "./dist/utils.d.ts",
"default": "./dist/utils.js"
},
"./types": {
"types": "./dist/types.d.ts",
"default": "./dist/types.js"
},
"./*": "./*"
},
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"*.d.ts",
"dist"
],
"scripts": {
"build": "premove dist && rollup -c",
"dev": "rollup -c --watch"
},
"dependencies": {
"@vitest/utils": "workspace:*",
"pathe": "catalog:",
"tinybench": "catalog:"
}
}
-65
View File
@@ -1,65 +0,0 @@
import { builtinModules, createRequire } from 'node:module'
import json from '@rollup/plugin-json'
import { defineConfig } from 'rollup'
import oxc from 'unplugin-oxc/rollup'
import { createDtsUtils } from '../../scripts/build-utils.js'
const require = createRequire(import.meta.url)
const pkg = require('./package.json')
const external = [
...builtinModules,
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
/^@?vitest(\/|$)/,
]
const entries = {
index: 'src/index.ts',
utils: 'src/utils/index.ts',
types: 'src/types.ts',
}
const dtsUtils = createDtsUtils()
const plugins = [
...dtsUtils.isolatedDecl(),
oxc({
transform: { target: 'node20' },
}),
json(),
]
export default defineConfig([
{
input: entries,
output: {
dir: 'dist',
format: 'esm',
entryFileNames: '[name].js',
chunkFileNames: 'chunk-[name].js',
},
external,
plugins,
onwarn,
},
{
input: dtsUtils.dtsInput(entries),
output: {
dir: 'dist',
entryFileNames: '[name].d.ts',
format: 'esm',
},
watch: false,
external,
plugins: dtsUtils.dts(),
onwarn,
},
])
function onwarn(message) {
if (['EMPTY_BUNDLE', 'CIRCULAR_DEPENDENCY'].includes(message.code)) {
return
}
console.error(message)
}
-24
View File
@@ -1,24 +0,0 @@
export { recordArtifact } from './artifact'
export { TestSyntaxError } from './errors'
export {
afterAll,
afterEach,
aroundAll,
aroundEach,
beforeAll,
beforeEach,
onTestFailed,
onTestFinished,
} from './hooks'
export { getFn, getHooks, setFn, setHooks } from './map'
export { collectTests, startTests, updateTask } from './run'
export {
createTaskCollector,
describe,
getCurrentSuite,
it,
suite,
test,
} from './suite'
export { getCurrentTest } from './test-state'
export type * from './types'
-72
View File
@@ -1,72 +0,0 @@
export type {
CancelReason,
FileSpecification,
TestTagDefinition,
TestTryOptions,
VitestRunner,
VitestRunnerConfig,
VitestRunnerConstructor,
VitestRunnerImportSource,
} from './types/runner'
export type {
AfterAllListener,
AfterEachListener,
AroundAllListener,
AroundEachListener,
BaselineData,
BeforeAllListener,
BeforeEachListener,
BrowserTraceArtifact,
FailureScreenshotArtifact,
File,
Fixture,
FixtureFn,
FixtureOptions,
Fixtures,
ImportDuration,
InferFixturesTypes,
OnTestFailedHandler,
OnTestFinishedHandler,
Retry,
RunMode,
RuntimeContext,
SequenceHooks,
SequenceSetupFiles,
SerializableRetry,
Suite,
SuiteAPI,
SuiteCollector,
SuiteFactory,
SuiteHooks,
SuiteOptions,
Task,
TaskBase,
TaskCustomOptions,
TaskEventData,
TaskEventPack,
TaskHook,
TaskMeta,
TaskPopulated,
TaskResult,
TaskResultPack,
TaskState,
TaskUpdateEvent,
Test,
TestAnnotation,
TestAnnotationArtifact,
TestAnnotationLocation,
TestAPI,
TestArtifact,
TestArtifactBase,
TestArtifactLocation,
TestArtifactRegistry,
TestAttachment,
TestBenchmark,
TestBenchmarkTask,
TestContext,
TestFunction,
TestOptions,
TestTags,
Use,
VisualRegressionArtifact,
} from './types/tasks'
-251
View File
@@ -1,251 +0,0 @@
import type { DiffOptions } from '@vitest/utils/diff'
import type {
File,
ImportDuration,
SequenceHooks,
SequenceSetupFiles,
SerializableRetry,
Suite,
TaskEventPack,
TaskResultPack,
Test,
TestAnnotation,
TestArtifact,
TestContext,
TestOptions,
TestTags,
} from './tasks'
/**
* This is a subset of Vitest config that's required for the runner to work.
*/
export interface VitestRunnerConfig {
root: string
setupFiles: string[]
name: string | undefined
passWithNoTests: boolean
testNamePattern: RegExp | undefined
allowOnly: boolean
sequence: {
shuffle?: boolean
concurrent?: boolean
seed: number
hooks: SequenceHooks
setupFiles: SequenceSetupFiles
}
chaiConfig: {
truncateThreshold?: number
} | undefined
taskTitleValueFormatTruncate: number
maxConcurrency: number
testTimeout: number
hookTimeout: number
retry: SerializableRetry
includeTaskLocation: boolean | undefined
tags: TestTagDefinition[]
tagsFilter: string[] | undefined
strictTags: boolean
/**
* @internal
*/
_diffOptions?: DiffOptions
mergeReportsLabel: string | undefined
}
/**
* Possible options to run a single file in a test.
*/
export interface FileSpecification {
filepath: string
// file can be marked via a jsdoc comment to have tags,
// these are _not_ tags to filter tests by
fileTags?: string[]
testLocations?: number[] | undefined
testNamePattern?: RegExp | undefined
testTagsFilter?: string[] | undefined
testIds?: string[] | undefined
}
export interface TestTagDefinition extends Omit<TestOptions, 'tags' | 'shuffle'> {
/**
* The name of the tag. This is what you use in the `tags` array in tests.
*/
name: keyof TestTags extends never
? string
: TestTags[keyof TestTags]
/**
* A description for the tag. This will be shown in the CLI help and UI.
*/
description?: string
/**
* Priority for merging options when multiple tags with the same options are applied to a test.
*
* Lower number means higher priority. E.g., priority 1 takes precedence over priority 3.
*/
priority?: number
}
export type VitestRunnerImportSource = 'collect' | 'setup'
export interface VitestRunnerConstructor {
new (config: VitestRunnerConfig): VitestRunner
}
export type CancelReason
= | 'keyboard-input'
| 'test-failure'
| (string & Record<string, never>)
export interface TestTryOptions {
retry: number
repeats: number
}
export interface VitestRunner {
/**
* First thing that's getting called before actually collecting and running tests.
*/
onBeforeCollect?: (paths: string[]) => unknown
/**
* Called after the file task was created but not collected yet.
*/
onCollectStart?: (file: File) => unknown
/**
* Called after collecting tests and before "onBeforeRun".
*/
onCollected?: (files: File[]) => unknown
/**
* Called when test runner should cancel next test runs.
* Runner should listen for this method and mark tests and suites as skipped in
* "onBeforeRunSuite" and "onBeforeRunTask" when called.
*/
cancel?: (reason: CancelReason) => unknown
/**
* Called before running a single test. Doesn't have "result" yet.
*/
onBeforeRunTask?: (test: Test) => unknown
/**
* Called before actually running the test function. Already has "result" with "state" and "startTime".
*/
onBeforeTryTask?: (
test: Test,
options: TestTryOptions,
) => unknown
/**
* When the task has finished running, but before cleanup hooks are called
*/
onTaskFinished?: (test: Test) => unknown
/**
* Called after result and state are set.
*/
onAfterRunTask?: (test: Test) => unknown
/**
* Called right after running the test function. Doesn't have new state yet. Will not be called, if the test function throws.
*/
onAfterTryTask?: (
test: Test,
options: TestTryOptions,
) => unknown
/**
* Called after the retry resolution happened. Unlike `onAfterTryTask`, the test now has a new state.
* All `after` hooks were also called by this point.
*/
onAfterRetryTask?: (
test: Test,
options: TestTryOptions,
) => unknown
/**
* Called before running a single suite. Doesn't have "result" yet.
*/
onBeforeRunSuite?: (suite: Suite) => unknown
/**
* Called after running a single suite. Has state and result.
*/
onAfterRunSuite?: (suite: Suite) => unknown
/**
* If defined, will be called instead of usual Vitest suite partition and handling.
* "before" and "after" hooks will not be ignored.
*/
runSuite?: (suite: Suite) => Promise<void>
/**
* If defined, will be called instead of usual Vitest handling. Useful, if you have your custom test function.
* "before" and "after" hooks will not be ignored.
*/
runTask?: (test: Test) => Promise<void>
/**
* Called, when a task is updated. The same as "onTaskUpdate" in a reporter, but this is running in the same thread as tests.
*/
onTaskUpdate?: (task: TaskResultPack[], events: TaskEventPack[]) => Promise<void>
/**
* Called when annotation is added via the `context.annotate` method.
*/
onTestAnnotate?: (test: Test, annotation: TestAnnotation) => Promise<TestAnnotation>
/**
* @experimental
*
* Called when artifacts are recorded on tests via the `recordArtifact` utility.
*/
onTestArtifactRecord?: <Artifact extends TestArtifact>(test: Test, artifact: Artifact) => Promise<Artifact>
/**
* Called before running all tests in collected paths.
*/
onBeforeRunFiles?: (files: File[]) => unknown
/**
* Called right after running all tests in collected paths.
*/
onAfterRunFiles?: (files: File[]) => unknown
/**
* Called when new context for a test is defined. Useful if you want to add custom properties to the context.
* If you only want to define custom context, consider using "beforeAll" in "setupFiles" instead.
*
* @see https://vitest.dev/advanced/runner#your-task-function
*/
extendTaskContext?: (context: TestContext) => TestContext
/**
* Called when test and setup files are imported. Can be called in two situations: when collecting tests and when importing setup files.
*/
importFile: (filepath: string, source: VitestRunnerImportSource) => unknown
/**
* Function that is called when the runner attempts to get the value when `test.extend` is used with `{ injected: true }`
*/
injectValue?: (key: string) => unknown
/**
* Gets the time spent importing each individual non-externalized file that Vitest collected.
*/
getImportDurations?: () => Record<string, ImportDuration>
/**
* Publicly available configuration.
*/
config: VitestRunnerConfig
/**
* The name of the current pool. Can affect how stack trace is inferred on the server side.
*/
pool?: string
/**
* The current Vite environment that processes the files on the server.
*/
viteEnvironment?: string
onCleanupWorkerContext?: (cleanup: () => unknown) => void
// eslint-disable-next-line ts/method-signature-style
trace?<T>(name: string, cb: () => T): T
// eslint-disable-next-line ts/method-signature-style
trace?<T>(name: string, attributes: Record<string, any>, cb: () => T): T
/** @internal */
_currentSpecification?: FileSpecification | undefined
/** @internal */
_currentTaskStartTime?: number
/** @internal */
_currentTaskTimeout?: number
}
-261
View File
@@ -1,261 +0,0 @@
import type { ParsedStack } from '@vitest/utils'
import type { File, Suite, TaskBase } from '../types/tasks'
import { processError } from '@vitest/utils/error'
import { parseSingleStack } from '@vitest/utils/source-map'
import { relative } from 'pathe'
/**
* If any tasks been marked as `only`, mark all other tasks as `skip`.
*/
export function interpretTaskModes(
file: Suite,
namePattern?: string | RegExp,
testLocations?: number[] | undefined,
testIds?: string[] | undefined,
testTagsFilter?: ((testTags: string[]) => boolean) | undefined,
onlyMode?: boolean,
parentIsOnly?: boolean,
allowOnly?: boolean,
): void {
const matchedLocations: number[] = []
const testLocationsSet = testLocations !== undefined && testLocations.length !== 0
? new Set(testLocations)
: undefined
const testIdsSet = testIds ? new Set(testIds) : undefined
const traverseSuite = (suite: Suite, parentIsOnly?: boolean, parentMatchedWithLocation?: boolean) => {
const suiteIsOnly = parentIsOnly || suite.mode === 'only'
// Check if any tasks in this suite have `.only` - if so, only those should run
const hasSomeTasksOnly = onlyMode && suite.tasks.some(
t => t.mode === 'only' || (t.type === 'suite' && someTasksAreOnly(t)),
)
suite.tasks.forEach((t) => {
// Check if either the parent suite or the task itself are marked as included
// If there are tasks with `.only` in this suite, only include those (not all tasks from describe.only)
const includeTask = hasSomeTasksOnly
? (t.mode === 'only' || (t.type === 'suite' && someTasksAreOnly(t)))
: (suiteIsOnly || t.mode === 'only')
if (onlyMode) {
if (t.type === 'suite' && (includeTask || someTasksAreOnly(t))) {
// Don't skip this suite
if (t.mode === 'only') {
checkAllowOnly(t, allowOnly)
t.mode = 'run'
}
}
else if (t.mode === 'run' && !includeTask) {
t.mode = 'skip'
}
else if (t.mode === 'only') {
checkAllowOnly(t, allowOnly)
t.mode = 'run'
}
}
let hasLocationMatch = parentMatchedWithLocation
// Match test location against provided locations, only run if present
// in `testLocations`. Note: if `includeTaskLocation` is not enabled,
// all test will be skipped.
if (testLocationsSet !== undefined) {
if (t.location && testLocationsSet.has(t.location.line)) {
t.mode = 'run'
matchedLocations.push(t.location.line)
hasLocationMatch = true
}
else if (parentMatchedWithLocation) {
t.mode = 'run'
}
else if (t.type === 'test') {
t.mode = 'skip'
}
}
if (t.type === 'test') {
if (namePattern && !getTaskFullName(t).match(namePattern)) {
t.mode = 'skip'
}
if (testIdsSet && !testIdsSet.has(t.id)) {
t.mode = 'skip'
}
if (testTagsFilter && !testTagsFilter(t.tags || [])) {
t.mode = 'skip'
}
}
else if (t.type === 'suite') {
if (t.mode === 'skip') {
skipAllTasks(t)
}
else if (t.mode === 'todo') {
todoAllTasks(t)
}
else {
traverseSuite(t, includeTask, hasLocationMatch)
}
}
})
// if all subtasks are skipped, mark as skip
if (suite.mode === 'run' || suite.mode === 'queued') {
if (suite.tasks.length && suite.tasks.every(i => i.mode !== 'run' && i.mode !== 'queued')) {
suite.mode = 'skip'
}
}
}
traverseSuite(file, parentIsOnly, false)
const nonMatching = testLocations?.filter(loc => !matchedLocations.includes(loc))
if (nonMatching && nonMatching.length !== 0) {
const message = nonMatching.length === 1
? `line ${nonMatching[0]}`
: `lines ${nonMatching.join(', ')}`
if (file.result === undefined) {
file.result = {
state: 'fail',
errors: [],
}
}
if (file.result.errors === undefined) {
file.result.errors = []
}
file.result.errors.push(
processError(new Error(`No test found in ${file.name} in ${message}`)),
)
}
}
function getTaskFullName(task: TaskBase): string {
return `${task.suite ? `${getTaskFullName(task.suite)} ` : ''}${task.name}`
}
export function someTasksAreOnly(suite: Suite): boolean {
return suite.tasks.some(
t => t.mode === 'only' || (t.type === 'suite' && someTasksAreOnly(t)),
)
}
function skipAllTasks(suite: Suite) {
suite.tasks.forEach((t) => {
if (t.mode === 'run' || t.mode === 'queued') {
t.mode = 'skip'
if (t.type === 'suite') {
skipAllTasks(t)
}
}
})
}
function todoAllTasks(suite: Suite) {
suite.tasks.forEach((t) => {
if (t.mode === 'run' || t.mode === 'queued') {
t.mode = 'todo'
if (t.type === 'suite') {
todoAllTasks(t)
}
}
})
}
function checkAllowOnly(task: TaskBase, allowOnly?: boolean) {
if (allowOnly) {
return
}
const error = processError(
new Error(
'[Vitest] Unexpected .only modifier. Remove it or pass --allowOnly argument to bypass this error',
),
)
task.result = {
state: 'fail',
errors: [error],
}
}
/* @__NO_SIDE_EFFECTS__ */
export function generateHash(str: string): string {
let hash = 0
if (str.length === 0) {
return `${hash}`
}
for (let i = 0; i < str.length; i++) {
const char = str.charCodeAt(i)
hash = (hash << 5) - hash + char
hash = hash & hash // Convert to 32bit integer
}
return `${hash}`
}
export function calculateSuiteHash(parent: Suite): void {
parent.tasks.forEach((t, idx) => {
t.id = `${parent.id}_${idx}`
if (t.type === 'suite') {
calculateSuiteHash(t)
}
})
}
interface HashMeta {
typecheck?: boolean
__vitest_label__?: string
}
export function createFileTask(
filepath: string,
root: string,
projectName: string | undefined,
pool?: string,
viteEnvironment?: string,
meta?: HashMeta,
): File {
const path = relative(root, filepath)
const file: File = {
id: generateFileHash(path, projectName, meta),
name: path,
fullName: path,
type: 'suite',
mode: 'queued',
filepath,
tasks: [],
meta: Object.assign(Object.create(null), meta),
projectName,
file: undefined!,
pool,
viteEnvironment,
}
file.file = file
return file
}
/**
* Generate a unique ID for a file based on its path and project name
* @param file File relative to the root of the project to keep ID the same between different machines
* @param projectName The name of the test project
*/
/* @__NO_SIDE_EFFECTS__ */
export function generateFileHash(
file: string,
projectName: string | undefined,
meta?: HashMeta,
): string {
const seed = [
file,
projectName || '',
meta?.typecheck ? '__typecheck__' : '',
meta?.__vitest_label__ || '',
].join('\0')
return generateHash(seed)
}
export function findTestFileStackTrace(testFilePath: string, error: string): ParsedStack | undefined {
// first line is the error message
const lines = error.split('\n').slice(1)
for (const line of lines) {
const stack = parseSingleStack(line)
if (stack && stack.file === testFilePath) {
return stack
}
}
}
-25
View File
@@ -1,25 +0,0 @@
export { type ChainableFunction, createChainable } from './chain'
export {
calculateSuiteHash,
createFileTask,
findTestFileStackTrace,
generateFileHash,
generateHash,
interpretTaskModes,
someTasksAreOnly,
} from './collect'
export { limitConcurrency } from './limit-concurrency'
export { partitionSuiteChildren } from './suite'
export { createTagsFilter, matchesTags, validateTags } from './tags'
export {
createTaskName,
getFullName,
getNames,
getSuites,
getTasks,
getTestName,
getTests,
hasFailed,
hasTests,
isTestCase,
} from './tasks'
-86
View File
@@ -1,86 +0,0 @@
import type { Arrayable } from '@vitest/utils'
import type { Suite, Task, Test } from '../types/tasks'
import { toArray } from '@vitest/utils/helpers'
export function isTestCase(s: Task): s is Test {
return s.type === 'test'
}
export function getTests(suite: Arrayable<Task>): Test[] {
const tests: Test[] = []
const arraySuites = toArray(suite)
for (const s of arraySuites) {
if (isTestCase(s)) {
tests.push(s)
}
else {
for (const task of s.tasks) {
if (isTestCase(task)) {
tests.push(task)
}
else {
const taskTests = getTests(task)
for (const test of taskTests) {
tests.push(test)
}
}
}
}
}
return tests
}
export function getTasks(tasks: Arrayable<Task> = []): Task[] {
return toArray(tasks).flatMap(s =>
isTestCase(s) ? [s] : [s, ...getTasks(s.tasks)],
)
}
export function getSuites(suite: Arrayable<Task>): Suite[] {
return toArray(suite).flatMap(s =>
s.type === 'suite' ? [s, ...getSuites(s.tasks)] : [],
)
}
export function hasTests(suite: Arrayable<Suite>): boolean {
return toArray(suite).some(s =>
s.tasks.some(c => isTestCase(c) || hasTests(c)),
)
}
export function hasFailed(suite: Arrayable<Task>): boolean {
return toArray(suite).some(
s =>
s.result?.state === 'fail' || (s.type === 'suite' && hasFailed(s.tasks)),
)
}
export function getNames(task: Task): string[] {
const names = [task.name]
let current: Task | undefined = task
while (current?.suite) {
current = current.suite
if (current?.name) {
names.unshift(current.name)
}
}
if (current !== task.file) {
names.unshift(task.file.name)
}
return names
}
export function getFullName(task: Task, separator = ' > '): string {
return getNames(task).join(separator)
}
export function getTestName(task: Task, separator = ' > '): string {
return getNames(task).slice(1).join(separator)
}
export function createTaskName(names: readonly (string | undefined)[], separator = ' > '): string {
return names.filter(name => name !== undefined).join(separator)
}
-12
View File
@@ -1,12 +0,0 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"types": ["node"],
"isolatedDeclarations": true
},
"include": ["./src/**/*.ts"],
"exclude": ["./dist"]
}
-1
View File
@@ -1 +0,0 @@
export * from './dist/types.js'
-1
View File
@@ -1 +0,0 @@
export * from './dist/utils.js'
@@ -1,4 +1,4 @@
import type { VisualRegressionArtifact } from '@vitest/runner'
import type { VisualRegressionArtifact } from 'vitest'
import { faker } from '@faker-js/faker'
import { describe, expect, it } from 'vitest'
import { userEvent } from 'vitest/browser'
@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { VisualRegressionArtifact } from '@vitest/runner'
import type { VisualRegressionArtifact } from 'vitest'
import { computed } from 'vue'
import ArtifactTemplate from '../ArtifactTemplate.vue'
import SmallTabs from './SmallTabs.vue'
@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { TestAttachment } from '@vitest/runner'
import type { TestAttachment } from 'vitest'
import { computed } from 'vue'
import { internalOrExternalUrl, isExternalAttachment } from '~/composables/attachments'
import VisualRegressionImageContainer from './VisualRegressionImageContainer.vue'
@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { VisualRegressionArtifact } from '@vitest/runner'
import type { VisualRegressionArtifact } from 'vitest'
import { computed, ref, useId } from 'vue'
import { internalOrExternalUrl } from '~/composables/attachments'
import VisualRegressionImageContainer from './VisualRegressionImageContainer.vue'
@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { File, Task } from '@vitest/runner'
import type { RunnerTestFile as File, RunnerTask as Task } from 'vitest'
import { hideAllPoppers } from 'floating-vue'
import { computed, ref } from 'vue'
@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { Task, TaskState } from '@vitest/runner'
import type { RunnerTask as Task, TaskState } from 'vitest'
import type { TaskTreeNodeType } from '~/composables/explorer/types'
import { Tooltip as VueTooltip } from 'floating-vue'
import { computed, nextTick } from 'vue'
@@ -1,10 +1,10 @@
<script setup lang="ts">
import { getNames } from '@vitest/runner/utils'
import { computed } from 'vue'
import { client, currentLogs as logs } from '~/composables/client'
import { isDark } from '~/composables/dark'
import { createAnsiToHtmlFilter } from '~/composables/error'
import { escapeHtml } from '~/utils/escape'
import { getNames } from '../../../../vitest/src/utils/tasks.ts'
import ViewConsoleOutputEntry from './ViewConsoleOutputEntry.vue'
const formattedLogs = computed(() => {
@@ -1,7 +1,6 @@
<script setup lang="ts">
import type { Task } from '@vitest/runner'
import type CodeMirror from 'codemirror'
import type { RunnerTestFile, TestAnnotation, TestError } from 'vitest'
import type { RunnerTestFile, RunnerTask as Task, TestAnnotation, TestError } from 'vitest'
import { until, useResizeObserver, watchDebounced } from '@vueuse/core'
import { createTooltip, destroyTooltip } from 'floating-vue'
import { computed, nextTick, onBeforeUnmount, ref, shallowRef, watch } from 'vue'
@@ -1,4 +1,4 @@
import type { TestAttachment } from '@vitest/runner'
import type { TestAttachment } from 'vitest'
import mime from 'mime/lite'
import { basename } from 'pathe'
import { isReport } from '~/constants'
@@ -9,11 +9,11 @@ import type {
} from 'vitest'
import type { BrowserRunnerState } from '../../../types'
import type { VitestClient } from './ws'
import { createFileTask, getTasks } from '@vitest/runner/utils'
import { computed, reactive as reactiveVue, ref, shallowRef, watch } from 'vue'
import { explorerTree } from '~/composables/explorer'
import { isFileNode } from '~/composables/explorer/utils'
import { isSuite as isTaskSuite } from '~/utils/task'
import { createFileTask, getTasks } from '../../../../vitest/src/utils/tasks'
import { ui } from '../../composables/api'
import { ENTRY_URL, isReport } from '../../constants'
import { parseError } from '../error'
@@ -8,9 +8,9 @@ import type {
} from 'vitest'
import type { Ref } from 'vue'
import type { RunState } from '../../../types'
import { createFileTask } from '@vitest/runner/utils'
import { computed, ref } from 'vue'
import { config } from '.'
import { createFileTask } from '../../../../vitest/src/utils/tasks'
export const testRunState: Ref<RunState> = ref('idle')
export const finished = computed(() => testRunState.value === 'idle')
+1 -2
View File
@@ -1,5 +1,4 @@
import type { Task, TestArtifactLocation } from '@vitest/runner'
import type { RunnerTestCase } from 'vitest'
import type { RunnerTestCase, RunnerTask as Task, TestArtifactLocation } from 'vitest'
import type { Ref, WritableComputedRef } from 'vue'
import CodeMirror from 'codemirror'
@@ -1,7 +1,6 @@
import type { File, Task, TaskResultPack, Test, TestArtifact } from '@vitest/runner'
import type { Arrayable } from '@vitest/utils'
import type { RunnerTestFile as File, RunnerTask as Task, RunnerTaskResultPack as TaskResultPack, RunnerTestCase as Test, TestArtifact } from 'vitest'
import type { CollectFilteredTests, CollectorInfo, Filter, FilteredTests, SearchMatcher } from '~/composables/explorer/types'
import { isTestCase } from '@vitest/runner/utils'
import { toArray } from '@vitest/utils/helpers'
import { client, findById } from '~/composables/client'
import { testRunState } from '~/composables/client/state'
@@ -502,7 +501,7 @@ function* testsCollector(suite: Arrayable<Task>): Generator<Test> {
let s: Task
for (let i = 0; i < arraySuites.length; i++) {
s = arraySuites[i]
if (isTestCase(s)) {
if (s.type === 'test') {
yield s
}
else {
@@ -1,4 +1,4 @@
import type { Task } from '@vitest/runner'
import type { RunnerTask as Task } from 'vitest'
import type { FileTreeNode, Filter, FilterResult, ParentTreeNode, SearchMatcher, UITaskTreeNode } from '~/composables/explorer/types'
import { client, config, findById } from '~/composables/client'
import { explorerTree } from '~/composables/explorer/index'
@@ -1,10 +1,11 @@
import type { File, Task } from '@vitest/runner'
import type { RunnerTestFile as File, RunnerTask as Task } from 'vitest'
import type { FileTreeNode, Filter, FilteredTests, SortUIType, TreeFilterState, UITaskTreeNode } from './types'
import { createTagsFilter } from '@vitest/runner/utils'
import { useLocalStorage } from '@vueuse/core'
import { computed, reactive, ref, shallowRef } from 'vue'
import { availableProjects } from '~/composables/client'
import { caseInsensitiveMatch } from '~/utils/task'
// importing from the source because we need to bundle it
import { createTagsFilter } from '../../../../vitest/src/runtime/runner/utils/tags'
import { config } from '../client'
import { explorerTree } from './index'
@@ -1,5 +1,4 @@
import type { File, TaskResultPack, TestArtifact } from '@vitest/runner'
import type { RunnerTaskEventPack } from 'vitest'
import type { RunnerTestFile as File, RunnerTaskEventPack, RunnerTaskResultPack as TaskResultPack, TestArtifact } from 'vitest'
import type {
CollectorInfo,
FilteredTests,
@@ -1,4 +1,4 @@
import type { RunMode, Task, TaskState } from '@vitest/runner'
import type { RunMode, RunnerTask as Task, TaskState } from 'vitest'
export type FilterResult = [match: boolean, node: UITaskTreeNode]
@@ -1,4 +1,4 @@
import type { File, Task } from '@vitest/runner'
import type { RunnerTestFile as File, RunnerTask as Task } from 'vitest'
import type {
FileTreeNode,
ParentTreeNode,
@@ -7,7 +7,6 @@ import type {
TestTreeNode,
UITaskTreeNode,
} from '~/composables/explorer/types'
import { isTestCase } from '@vitest/runner/utils'
import { client, config } from '~/composables/client'
import { explorerTree } from '~/composables/explorer/index'
import { openedTreeItemsSet } from '~/composables/explorer/state'
@@ -159,7 +158,7 @@ export function createOrUpdateNodeTask(id: string) {
const task = client.state.idMap.get(id)
// if it is not a test just return
if (!task || !isTestCase(task)) {
if (!task || task.type !== 'test') {
return
}
@@ -191,7 +190,7 @@ export function createOrUpdateNode(
taskNode.state = task.result?.state
}
else {
if (isTestCase(task)) {
if (task.type === 'test') {
taskNode = {
id: task.id,
fileId: task.file.id,
+1 -1
View File
@@ -1,4 +1,4 @@
import type { File, Task } from '@vitest/runner'
import type { RunnerTestFile as File, RunnerTask as Task } from 'vitest'
import type { Params } from './params'
import { useLocalStorage, watchOnce } from '@vueuse/core'
import { computed, nextTick, reactive, ref, watch } from 'vue'
+1 -2
View File
@@ -1,5 +1,4 @@
import type { TestAttachment } from '@vitest/runner'
import type { SerializedError } from 'vitest'
import type { SerializedError, TestAttachment } from 'vitest'
import type { HTMLOptions, Reporter, ResolvedConfig, RunnerTask, RunnerTestFile, TestModule, Vitest } from 'vitest/node'
import type { HTMLReportMetadata } from '../client/composables/client/static'
import { existsSync, promises as fs, readFileSync } from 'node:fs'
-1
View File
@@ -74,7 +74,6 @@
"@vitest/browser-playwright": "workspace:*",
"@vitest/browser-preview": "workspace:*",
"@vitest/browser-webdriverio": "workspace:*",
"@vitest/runner": "workspace:*",
"@vueuse/core": "catalog:",
"ansi-to-html": "^0.7.2",
"birpc": "catalog:",
+1 -1
View File
@@ -24,6 +24,7 @@
"sideEffects": false,
"imports": {
"#module-evaluator": {
"__vitest_source__": "./src/runtime/moduleRunner/moduleEvaluator.ts",
"types": "./dist/module-evaluator.d.ts",
"default": "./dist/module-evaluator.js"
},
@@ -169,7 +170,6 @@
"@types/chai": "catalog:",
"@vitest/mocker": "workspace:*",
"@vitest/pretty-format": "workspace:*",
"@vitest/runner": "workspace:*",
"@vitest/spy": "workspace:*",
"@vitest/utils": "workspace:*",
"chai": "catalog:",
+3 -2
View File
@@ -29,6 +29,9 @@ const entries = {
'nodejs-worker-loader': 'src/runtime/nodejsWorkerLoader.ts',
'traces': 'src/utils/traces.ts',
// just so that we have a separate chunk, this is not a public api
'task-utils': 'src/utils/tasks.ts',
// for performance reasons we bundle them separately so we don't import everything at once
// 'worker': 'src/runtime/worker.ts',
'workers/forks': 'src/runtime/workers/forks.ts',
@@ -71,8 +74,6 @@ const external = [
'@vitest/utils/diff',
'@vitest/utils/error',
'@vitest/utils/source-map',
'@vitest/runner/utils',
'@vitest/runner/types',
/@vitest\/utils\/\w+/,
/@vitest\/mocker\/\w+/,
+1 -1
View File
@@ -1,4 +1,3 @@
import type { File, TaskEventPack, TaskResultPack, TestAnnotation, TestArtifact } from '@vitest/runner'
import type { SerializedError } from '@vitest/utils'
import type { IncomingMessage } from 'node:http'
import type { ViteDevServer } from 'vite'
@@ -7,6 +6,7 @@ import type { Vitest } from '../node/core'
import type { TestCase, TestModule } from '../node/reporters/reported-tasks'
import type { TestSpecification } from '../node/test-specification'
import type { Reporter } from '../node/types/reporter'
import type { File, TaskEventPack, TaskResultPack, TestAnnotation, TestArtifact } from '../runtime/runner/types'
import type { LabelColor, ModuleGraphData, UserConsoleLog } from '../types/general'
import type {
ExternalResult,
+1 -1
View File
@@ -1,7 +1,7 @@
import type { File, TaskEventPack, TaskResultPack, TestAnnotation, TestArtifact } from '@vitest/runner'
import type { Awaitable } from '@vitest/utils'
import type { BirpcReturn } from 'birpc'
import type { SerializedRootConfig } from '../runtime/config'
import type { File, TaskEventPack, TaskResultPack, TestAnnotation, TestArtifact } from '../runtime/runner/types'
import type { SerializedTestSpecification } from '../runtime/types/utils'
import type { LabelColor, ModuleGraphData, UserConsoleLog } from '../types/general'
import type { ModuleDefinitionDurationsDiagnostic, UntrackedModuleDefinitionDiagnostic } from '../types/module-locations'
@@ -1,5 +1,5 @@
import type { Assertion, ExpectStatic, MatcherState } from '@vitest/expect'
import type { TaskPopulated, Test } from '@vitest/runner'
import type { TaskPopulated, Test } from '../../runtime/runner/types'
import {
addCustomEqualityTesters,
ASYMMETRIC_MATCHERS_OBJECT,
@@ -9,7 +9,7 @@ import {
GLOBAL_EXPECT,
setState,
} from '@vitest/expect'
import { getCurrentTest } from '@vitest/runner'
import { getCurrentTest } from '../../runtime/runner/test-state'
import { getWorkerState } from '../../runtime/utils'
import { benchMatchers } from './bench'
import { createExpectPoll } from './poll'
@@ -1,5 +1,5 @@
import type { Assertion, ExpectStatic } from '@vitest/expect'
import type { Test } from '@vitest/runner'
import type { Test } from '../../runtime/runner/types'
import { chai } from '@vitest/expect'
import { delay, getSafeTimers } from '@vitest/utils/timers'
import { getWorkerState } from '../../runtime/utils'
@@ -1,15 +1,15 @@
import type { AsyncExpectationResult, ChaiPlugin, ExpectationResult, MatcherState, SyncExpectationResult } from '@vitest/expect'
import type { Test } from '@vitest/runner'
import type { DomainSnapshotAdapter } from '@vitest/snapshot'
import type { Test } from '../../runtime/runner/types'
import { chai, createAssertionMessage, equals, iterableEquality, recordAsyncExpect, subsetEquality, wrapAssertion } from '@vitest/expect'
import { TestSyntaxError } from '@vitest/runner'
import { getNames } from '@vitest/runner/utils'
import {
addSerializer,
SnapshotClient,
stripSnapshotIndentation,
} from '@vitest/snapshot'
import { TestSyntaxError } from '../../runtime/runner/errors'
import { getWorkerState } from '../../runtime/utils'
import { getNames } from '../../utils/tasks'
let _client: SnapshotClient
+3 -7
View File
@@ -1,20 +1,16 @@
import type { File, Suite, Task, Test } from '@vitest/runner'
import type { File, Suite, Task, Test } from '../runtime/runner/types'
import type { TestError } from '../types/general'
import type { TestProject } from './project'
import { promises as fs } from 'node:fs'
import { originalPositionFor, TraceMap } from '@jridgewell/trace-mapping'
import {
calculateSuiteHash,
createFileTask as createFileTaskOriginal,
createTaskName,
validateTags,
} from '@vitest/runner/utils'
import { unique } from '@vitest/utils/helpers'
import { ancestor as walkAst } from 'acorn-walk'
import { relative } from 'pathe'
import { parseAst } from 'vite'
import { validateTags } from '../runtime/runner/utils/tags'
import { createIndexLocationsMap } from '../utils/base'
import { createDebugger } from '../utils/debugger'
import { calculateSuiteHash, createFileTask as createFileTaskOriginal, createTaskName } from '../utils/tasks'
import { detectCodeBlock } from '../utils/test-helpers'
interface ParsedFile extends File {
+1 -1
View File
@@ -1,4 +1,4 @@
import type { BaselineData } from '@vitest/runner'
import type { BaselineData } from '../runtime/runner/types'
import type { TestProject } from './project'
import { existsSync } from 'node:fs'
import { mkdir, readFile, writeFile } from 'node:fs/promises'
+1 -1
View File
@@ -1,4 +1,4 @@
import type { File } from '@vitest/runner'
import type { File } from '../../runtime/runner/types'
import type { Logger } from '../logger'
import type { ResolvedConfig } from '../types/config'
import fs, { existsSync } from 'node:fs'
+4 -3
View File
@@ -1,9 +1,9 @@
import type { CancelReason, File } from '@vitest/runner'
import type { Awaitable } from '@vitest/utils'
import type { Writable } from 'node:stream'
import type { ViteDevServer } from 'vite'
import type { ModuleRunner } from 'vite/module-runner'
import type { SerializedCoverageConfig, SerializedRootConfig } from '../runtime/config'
import type { CancelReason, File } from '../runtime/runner/types'
import type { ArgumentsType, ProvidedContext, UserConsoleLog } from '../types/general'
import type { SourceModuleDiagnostic, SourceModuleLocations } from '../types/module-locations'
import type { CliOptions } from './cli/cli-api'
@@ -18,7 +18,6 @@ import type { Reporter } from './types/reporter'
import type { TestRunResult } from './types/tests'
import type { VCSProvider } from './vcs/vcs'
import os, { tmpdir } from 'node:os'
import { createTagsFilter, getTasks, hasFailed, interpretTaskModes, limitConcurrency, someTasksAreOnly } from '@vitest/runner/utils'
import { SnapshotManager } from '@vitest/snapshot/manager'
import { deepClone, deepMerge, nanoid, toArray } from '@vitest/utils/helpers'
import { serializeValue } from '@vitest/utils/serialize'
@@ -26,9 +25,11 @@ import { join, normalize, relative } from 'pathe'
import { isRunnableDevEnvironment } from 'vite'
import { version } from '../../package.json' with { type: 'json' }
import { distDir } from '../paths'
import { createTagsFilter } from '../runtime/runner/utils/tags'
import { wildcardPatternToRegExp } from '../utils/base'
import { limitConcurrency } from '../utils/limit-concurrency'
import { NativeModuleRunner } from '../utils/nativeModuleRunner'
import { convertTasksToEvents } from '../utils/tasks'
import { convertTasksToEvents, getTasks, hasFailed, interpretTaskModes, someTasksAreOnly } from '../utils/tasks'
import { Traces } from '../utils/traces'
import { astCollectTests, createFailedFileTask } from './ast-collect'
import { BrowserSessions } from './browser/sessions'
@@ -1,5 +1,5 @@
import type { ImportDuration } from '@vitest/runner'
import type { EnvironmentModuleGraph, TransformResult } from 'vite'
import type { ImportDuration } from '../runtime/runner/types'
import type {
ModuleDefinitionDiagnostic,
ModuleDefinitionDurationsDiagnostic,
+1 -1
View File
@@ -1,6 +1,6 @@
import type { Context, Span } from '@opentelemetry/api'
import type { FileSpecification } from '@vitest/runner'
import type { DeferPromise } from '@vitest/utils/helpers'
import type { FileSpecification } from '../../runtime/runner/types'
import type { Traces } from '../../utils/traces'
import type { Vitest } from '../core'
import type { ProcessPool } from '../pool'
@@ -1,14 +1,14 @@
import type { FileSpecification } from '@vitest/runner'
import type { DeferPromise } from '@vitest/utils'
import type { FileSpecification } from '../../../runtime/runner/types'
import type { TypecheckResults } from '../../../typecheck/typechecker'
import type { Vitest } from '../../core'
import type { TestProject } from '../../project'
import type { TestRunEndReason } from '../../types/reporter'
import type { PoolOptions, PoolWorker, WorkerRequest, WorkerResponse } from '../types'
import EventEmitter from 'node:events'
import { hasFailed } from '@vitest/runner/utils'
import { createDefer } from '@vitest/utils/helpers'
import { Typechecker } from '../../../typecheck/typechecker'
import { hasFailed } from '../../../utils/tasks'
/** @experimental */
export class TypecheckPoolWorker implements PoolWorker {
@@ -9,12 +9,12 @@ import type {
} from '../types/config'
import { existsSync, readdirSync, statSync } from 'node:fs'
import os from 'node:os'
import { limitConcurrency } from '@vitest/runner/utils'
import { deepClone } from '@vitest/utils/helpers'
import { basename, dirname, relative, resolve } from 'pathe'
import { glob, isDynamicPattern } from 'tinyglobby'
import { mergeConfig } from 'vite'
import { configFiles as defaultConfigFiles } from '../../constants'
import { limitConcurrency } from '../../utils/limit-concurrency'
import { VitestFilteredOutProjectError } from '../errors'
import { initializeProject, TestProject } from '../project'
+2 -3
View File
@@ -1,5 +1,5 @@
import type { File, Task, TestAnnotation, TestBenchmark, TestBenchmarkTask } from '@vitest/runner'
import type { ParsedStack, SerializedError } from '@vitest/utils'
import type { File, Task, TestAnnotation, TestBenchmark, TestBenchmarkTask } from '../../runtime/runner/types'
import type { AsyncLeak, TestError, UserConsoleLog } from '../../types/general'
import type { Vitest } from '../core'
import type { TestSpecification } from '../test-specification'
@@ -7,14 +7,13 @@ import type { Reporter, TestRunEndReason } from '../types/reporter'
import type { TestCase, TestCollection, TestModule, TestModuleState, TestResult, TestSuite, TestSuiteState } from './reported-tasks'
import { readFileSync } from 'node:fs'
import { performance } from 'node:perf_hooks'
import { getSuites, getTestName, getTests, hasFailed } from '@vitest/runner/utils'
import { toArray } from '@vitest/utils/helpers'
import { parseStacktrace } from '@vitest/utils/source-map'
import { relative } from 'pathe'
import c from 'tinyrainbow'
import { groupBy } from '../../utils/base'
import { isTTY } from '../../utils/env'
import { hasFailedSnapshot } from '../../utils/tasks'
import { getSuites, getTestName, getTests, hasFailed, hasFailedSnapshot } from '../../utils/tasks'
import { generateCodeFrame, printStack } from '../printError'
import { BENCH_TABLE_HEAD, computeBenchColumnWidths, padBenchRow, renderBenchmarkRow } from './renderers/benchmark-table'
import { F_CHECK, F_DOWN_RIGHT, F_POINTER } from './renderers/figures'
+1 -1
View File
@@ -1,6 +1,6 @@
import type { File } from '@vitest/runner'
import type { SerializedError } from '@vitest/utils'
import type { DevEnvironment, EnvironmentModuleNode } from 'vite'
import type { File } from '../../runtime/runner/types'
import type { Vitest } from '../core'
import type { TestProject } from '../project'
import type { Reporter } from '../types/reporter'
+1 -1
View File
@@ -1,6 +1,6 @@
import type { Test } from '@vitest/runner'
import type { SerializedError } from '@vitest/utils'
import type { Writable } from 'node:stream'
import type { Test } from '../../runtime/runner/types'
import type { Vitest } from '../core'
import type { TestSpecification } from '../test-specification'
import type { TestRunEndReason } from '../types/reporter'
@@ -1,14 +1,14 @@
import type { TestAnnotation } from '@vitest/runner'
import type { SerializedError } from '@vitest/utils'
import type { TestAnnotation } from '../../runtime/runner/types'
import type { Vitest } from '../core'
import type { TestProject } from '../project'
import type { Reporter } from '../types/reporter'
import type { TestCase, TestModule } from './reported-tasks'
import { writeFileSync } from 'node:fs'
import { stripVTControlCharacters } from 'node:util'
import { getFullName, getTasks } from '@vitest/runner/utils'
import { deepMerge } from '@vitest/utils/helpers'
import { relative } from 'pathe'
import { getFullName, getTasks } from '../../utils/tasks'
import { noun } from './renderers/utils'
export interface GithubActionsReporterOptions {
+2 -2
View File
@@ -1,13 +1,13 @@
import type { Suite, TaskMeta, TaskState, TestBenchmark } from '@vitest/runner'
import type { SnapshotSummary } from '@vitest/snapshot'
import type { CoverageMap } from 'istanbul-lib-coverage'
import type { Suite, TaskMeta, TaskState, TestBenchmark } from '../../runtime/runner/types'
import type { Vitest } from '../core'
import type { Reporter } from '../types/reporter'
import type { TestModule } from './reported-tasks'
import { existsSync, promises as fs } from 'node:fs'
import { getSuites, getTests } from '@vitest/runner/utils'
import { dirname, resolve } from 'pathe'
import { getOutputFile } from '../../utils/config-helpers'
import { getSuites, getTests } from '../../utils/tasks'
// 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)
+2 -2
View File
@@ -1,5 +1,5 @@
import type { Task } from '@vitest/runner'
import type { SerializedError } from '@vitest/utils'
import type { Task } from '../../runtime/runner/types'
import type { Vitest } from '../core'
import type { ErrorOptions } from '../logger'
import type { Reporter } from '../types/reporter'
@@ -8,9 +8,9 @@ import { existsSync, promises as fs } from 'node:fs'
import { hostname } from 'node:os'
import { stripVTControlCharacters } from 'node:util'
import { getSuites } from '@vitest/runner/utils'
import { basename, dirname, relative, resolve } from 'pathe'
import { getOutputFile } from '../../utils/config-helpers'
import { getSuites } from '../../utils/tasks'
import { renderBenchmarkTableText } from './renderers/benchmark-table'
import { IndentedLogger } from './renderers/indented-logger'
@@ -1,4 +1,4 @@
import type { TestBenchmark, TestBenchmarkTask } from '@vitest/runner'
import type { TestBenchmark, TestBenchmarkTask } from '../../../runtime/runner/types'
import { stripVTControlCharacters } from 'node:util'
export const BENCH_TABLE_HEAD: string[] = [
@@ -1,6 +1,6 @@
import type { Task } from '@vitest/runner'
import type { SnapshotSummary } from '@vitest/snapshot'
import type { Formatter } from 'tinyrainbow'
import type { Task } from '../../../runtime/runner/types'
import type { TestProject } from '../../project'
import { stripVTControlCharacters } from 'node:util'
import { truncateString as utilsTruncateString } from '@vitest/utils/display'
@@ -1,3 +1,5 @@
import type { SerializedError, TestError } from '@vitest/utils'
import type { DevEnvironment } from 'vite'
import type {
ImportDuration,
Task as RunnerTask,
@@ -9,9 +11,7 @@ import type {
TestAnnotation,
TestArtifact,
TestBenchmark,
} from '@vitest/runner'
import type { SerializedError, TestError } from '@vitest/utils'
import type { DevEnvironment } from 'vite'
} from '../../runtime/runner/types'
import type { UserConsoleLog } from '../../types/general'
import type { TestProject } from '../project'
import type { TestSpecification } from '../test-specification'
@@ -1,4 +1,4 @@
import type { Task } from '@vitest/runner'
import type { Task } from '../../runtime/runner/types'
import type { Vitest } from '../core'
import type { TestModule } from './reported-tasks'
import { TapReporter } from './tap'
+1 -1
View File
@@ -1,5 +1,5 @@
import type { Task } from '@vitest/runner'
import type { ParsedStack, TestError } from '@vitest/utils'
import type { Task } from '../../runtime/runner/types'
import type { Vitest } from '../core'
import type { Reporter } from '../types/reporter'
import type { TestModule } from './reported-tasks'
@@ -1,6 +1,6 @@
import type { TestCase, TestModule } from './reported-tasks'
import { getTestName } from '@vitest/runner/utils'
import c from 'tinyrainbow'
import { getTestName } from '../../utils/tasks'
import { DefaultReporter } from './default'
import { F_RIGHT } from './renderers/figures'
import { separator } from './renderers/utils'
+2 -2
View File
@@ -1,11 +1,11 @@
import type { File, FileSpecification, Task, TaskResultPack } from '@vitest/runner'
import type { File, FileSpecification, Task, TaskResultPack } from '../runtime/runner/types'
import type { AsyncLeak, UserConsoleLog } from '../types/general'
import type { TestProject } from './project'
import type { MergedBlobs } from './reporters/blob'
import type { OnUnhandledErrorCallback } from './types/config'
import { createFileTask, generateFileHash } from '@vitest/runner/utils'
import { relative } from 'pathe'
import { defaultBrowserPort } from '../constants'
import { createFileTask, generateFileHash } from '../utils/tasks'
import { TestCase, TestModule, TestSuite } from './reporters/reported-tasks'
function isAggregateError(err: unknown): err is AggregateError {
+2 -3
View File
@@ -1,9 +1,8 @@
import type { File, Task } from '@vitest/runner'
import type { Writable } from 'node:stream'
import type { File, Task } from '../runtime/runner/types'
import type { Vitest } from './core'
import type { FilterObject } from './watch-filter'
import readline from 'node:readline'
import { isTestCase } from '@vitest/runner/utils'
import { relative, resolve } from 'pathe'
import prompt from 'prompts'
import c from 'tinyrainbow'
@@ -41,7 +40,7 @@ ${keys
}
function* traverseFilteredTestNames(parentName: string, filter: RegExp, t: Task): Generator<FilterObject> {
if (isTestCase(t)) {
if (t.type === 'test') {
if (t.name.match(filter)) {
const displayName = `${parentName} > ${t.name}`
yield { key: t.name, toString: () => displayName }
+1 -1
View File
@@ -1,4 +1,4 @@
import type { TestTagDefinition } from '@vitest/runner'
import type { TestTagDefinition } from '../runtime/runner/types'
import type { TestProject } from './project'
export function populateProjectsTags(rootProject: TestProject, projects: TestProject[]): void {
+2 -2
View File
@@ -1,3 +1,4 @@
import type { SerializedError } from '@vitest/utils'
import type {
File as RunnerTestFile,
TaskEventData,
@@ -7,8 +8,7 @@ import type {
TestArtifact,
TestAttachment,
TestBenchmark,
} from '@vitest/runner'
import type { SerializedError } from '@vitest/utils'
} from '../runtime/runner/types'
import type { UserConsoleLog } from '../types/general'
import type { Vitest } from './core'
import type { TestProject } from './project'
@@ -2,8 +2,8 @@ import type { SerializedTestSpecification } from '../runtime/types/utils'
import type { TestProject } from './project'
import type { TestModule } from './reporters/reported-tasks'
import type { Pool } from './types/config'
import { generateFileHash } from '@vitest/runner/utils'
import { relative } from 'pathe'
import { generateFileHash } from '../utils/tasks'
export interface TestSpecificationOptions {
testNamePattern?: RegExp
+1 -1
View File
@@ -1,10 +1,10 @@
import type { MockedModule } from '@vitest/mocker'
import type { CancelReason } from '@vitest/runner'
import type { Awaitable, ParsedStack, TestError } from '@vitest/utils'
import type { StackTraceParserOptions } from '@vitest/utils/source-map'
import type { Plugin, ViteDevServer } from 'vite'
import type { BrowserCommands, CDPSession, MarkOptions } from 'vitest/browser'
import type { BrowserTraceViewMode } from '../../runtime/config'
import type { CancelReason } from '../../runtime/runner/types'
import type { BrowserTesterOptions } from '../../types/browser'
import type { OTELCarrier } from '../../utils/traces'
import type { TestProject } from '../project'
+2 -2
View File
@@ -1,12 +1,12 @@
import type { Config as FakeTimersConfig } from '@sinonjs/fake-timers'
import type { PrettyFormatOptions } from '@vitest/pretty-format'
import type { SequenceHooks, SequenceSetupFiles, SerializableRetry, TestTagDefinition } from '@vitest/runner'
import type { SnapshotStateOptions } from '@vitest/snapshot'
import type { Arrayable } from '@vitest/utils'
import type { SerializedDiffOptions } from '@vitest/utils/diff'
import type { AliasOptions, ConfigEnv, DepOptimizationConfig, ServerOptions, UserConfig as ViteUserConfig } from 'vite'
import type { ChaiConfig } from '../../integrations/chai/config'
import type { SerializedConfig } from '../../runtime/config'
import type { SequenceHooks, SequenceSetupFiles, SerializableRetry, TestTagDefinition } from '../../runtime/runner/types'
import type { LabelColor, ParsedStack, ProvidedContext, TestError } from '../../types/general'
import type { HappyDOMOptions } from '../../types/happy-dom-options'
import type { JSDOMOptions } from '../../types/jsdom-options'
@@ -27,9 +27,9 @@ import type { Reporter } from './reporter'
export type { CoverageOptions, ResolvedCoverageOptions }
export type { BenchmarkUserOptions }
export type { RuntimeConfig, SerializedConfig } from '../../runtime/config'
export type { SequenceHooks, SequenceSetupFiles } from '../../runtime/runner/types'
export type { BrowserConfigOptions, BrowserInstanceOption, BrowserScript } from './browser'
export type { CoverageIstanbulOptions, CoverageV8Options } from './coverage'
export type { SequenceHooks, SequenceSetupFiles } from '@vitest/runner'
export type BuiltinEnvironment
= | 'node'
+1 -1
View File
@@ -1,5 +1,5 @@
import type { File, TaskEventPack, TaskResultPack, TestAnnotation, TestArtifact, TestBenchmark } from '@vitest/runner'
import type { Awaitable, SerializedError } from '@vitest/utils'
import type { File, TaskEventPack, TaskResultPack, TestAnnotation, TestArtifact, TestBenchmark } from '../../runtime/runner/types'
import type { UserConsoleLog } from '../../types/general'
import type { Vitest } from '../core'
import type { TestProject } from '../project'
+2 -1
View File
@@ -3,12 +3,13 @@ export {
stopCoverageInsideWorker,
takeCoverageInsideWorker,
} from '../integrations/coverage'
export { collectTests, startTests } from '../runtime/runner/run'
export type { FileSpecification } from '../runtime/runner/types'
export {
loadDiffConfig,
loadSnapshotSerializers,
setupCommonEnv,
} from '../runtime/setup-common'
export { collectTests, startTests } from '@vitest/runner'
export * as SpyModule from '@vitest/spy'
export type { ParsedStack, StringifyOptions } from '@vitest/utils'
export {
+1 -1
View File
@@ -19,7 +19,7 @@ export {
defaultInclude,
} from '../defaults'
export type { WatcherTriggerPattern } from '../node/watcher'
export type { TestTagDefinition } from '@vitest/runner'
export type { TestTagDefinition } from '../runtime/runner/types'
export { mergeConfig } from 'vite'
export type { Plugin } from 'vite'
+62 -54
View File
@@ -1,3 +1,4 @@
import type { SerializedConfig } from '../runtime/config'
import type { SerializedTestSpecification } from '../runtime/types/utils'
import type {
ModuleDefinitionDiagnostic,
@@ -51,53 +52,12 @@ export type {
SerializedRootConfig,
} from '../runtime/config'
/** @deprecated use `SerializedConfig` instead */
export type TestRunnerConfig = SerializedConfig
export { VitestEvaluatedModules as EvaluatedModules } from '../runtime/moduleRunner/evaluatedModules'
export { TestRunner } from '../runtime/runners/test'
export { assertType } from '../typecheck/assertType'
export type { AssertType } from '../typecheck/assertType'
export { expectTypeOf } from '../typecheck/expectTypeOf'
export type { ExpectTypeOf } from '../typecheck/expectTypeOf'
export type { BrowserTesterOptions } from '../types/browser'
export type {
AfterSuiteRunMeta,
LabelColor,
ModuleGraphData,
ParsedStack,
ProvidedContext,
TestError,
UserConsoleLog,
} from '../types/general'
export type {
RunnerRPC,
RuntimeRPC,
} from '../types/rpc'
export type { BrowserUI } from '../types/ui'
export type {
ContextRPC,
ContextTestEnvironment,
TestExecutionMethod,
WorkerGlobalState,
} from '../types/worker'
export type {
Assertion,
AsymmetricMatchersContaining,
AsyncExpectationResult as AsyncMatcherResult,
DeeplyAllowMatchers,
ExpectStatic,
JestAssertion,
RawMatcherFn as Matcher,
ExpectationResult as MatcherResult,
Matchers,
MatchersObject,
MatcherState,
SyncExpectationResult as SyncMatcherResult,
} from '@vitest/expect'
export { recordArtifact } from '../runtime/runner/artifact'
export {
afterAll,
afterEach,
@@ -105,16 +65,19 @@ export {
aroundEach,
beforeAll,
beforeEach,
describe,
it,
onTestFailed,
onTestFinished,
recordArtifact,
} from '../runtime/runner/hooks'
export {
describe,
it,
suite,
test,
} from '@vitest/runner'
} from '../runtime/runner/suite'
export type {
BaselineData,
BrowserTraceArtifact,
FailureScreenshotArtifact,
ImportDuration,
OnTestFailedHandler,
OnTestFinishedHandler,
@@ -147,14 +110,59 @@ export type {
TestContext,
TestFunction,
TestOptions,
VitestRunnerConfig as TestRunnerConfig,
TestTagDefinition,
TestTags,
VitestRunner as VitestTestRunner,
} from '@vitest/runner'
TestTryOptions,
export type { CancelReason } from '@vitest/runner'
VisualRegressionArtifact,
} from '../runtime/runner/types'
export type { CancelReason, VitestRunner as VitestTestRunner } from '../runtime/runner/types'
export { TestRunner } from '../runtime/runners/test'
export { assertType } from '../typecheck/assertType'
export type { AssertType } from '../typecheck/assertType'
export { expectTypeOf } from '../typecheck/expectTypeOf'
export type { ExpectTypeOf } from '../typecheck/expectTypeOf'
export type { BrowserTesterOptions } from '../types/browser'
export type {
AfterSuiteRunMeta,
LabelColor,
ModuleGraphData,
ParsedStack,
ProvidedContext,
TestError,
UserConsoleLog,
} from '../types/general'
export type {
RunnerRPC,
RuntimeRPC,
} from '../types/rpc'
export type { BrowserUI } from '../types/ui'
export type {
ContextRPC,
ContextTestEnvironment,
TestExecutionMethod,
WorkerGlobalState,
} from '../types/worker'
export type {
Assertion,
AsymmetricMatchersContaining,
AsyncExpectationResult as AsyncMatcherResult,
DeeplyAllowMatchers,
ExpectStatic,
JestAssertion,
RawMatcherFn as Matcher,
ExpectationResult as MatcherResult,
Matchers,
MatchersObject,
MatcherState,
SyncExpectationResult as SyncMatcherResult,
} from '@vitest/expect'
export type {
DomainMatchResult,
+1 -2
View File
@@ -178,9 +178,9 @@ export type {
RawErrsMap as TypeCheckRawErrorsMap,
RootAndTarget as TypeCheckRootAndTarget,
} from '../typecheck/types'
export type { TestExecutionMethod as TestExecutionType } from '../types/worker'
export { createDebugger } from '../utils/debugger'
export { generateFileHash } from '../utils/tasks'
export type {
RunnerTask,
RunnerTaskResult,
@@ -189,7 +189,6 @@ export type {
RunnerTestFile,
RunnerTestSuite,
} from './index'
export { generateFileHash } from '@vitest/runner/utils'
export type { SerializedError } from '@vitest/utils'
export {
+3 -1
View File
@@ -12,12 +12,14 @@ import { getWorkerState } from '../runtime/utils'
export { environments as builtinEnvironments } from '../integrations/env/index'
export { populateGlobal } from '../integrations/env/utils'
export { VitestNodeSnapshotEnvironment as VitestSnapshotEnvironment } from '../integrations/snapshot/environments/node'
export type { SerializedConfig } from '../runtime/config'
export type { VitestRunner } from '../runtime/runner/types'
export type {
Environment,
EnvironmentReturn,
VmEnvironmentReturn,
} from '../types/environment'
export type { VitestRunner, VitestRunnerConfig } from '@vitest/runner'
export type { SnapshotEnvironment } from '@vitest/snapshot/environment'
// #region internal
+1 -1
View File
@@ -1,4 +1,3 @@
import type { BaselineData, Test, TestBenchmark, TestBenchmarkTask } from '@vitest/runner'
import type {
BenchOptions as BenchCompareOptions,
Fn,
@@ -9,6 +8,7 @@ import type {
Task as TinybenchTask,
} from 'tinybench'
import type { SerializedConfig } from './config'
import type { BaselineData, Test, TestBenchmark, TestBenchmarkTask } from './runner/types'
import { isAbsolute, relative } from 'pathe'
import { Bench as Tinybench } from 'tinybench'
import c from 'tinyrainbow'
+33 -3
View File
@@ -1,14 +1,44 @@
import type { Config as FakeTimersConfig } from '@sinonjs/fake-timers'
import type { PrettyFormatOptions } from '@vitest/pretty-format'
import type { SequenceHooks, VitestRunnerConfig } from '@vitest/runner'
import type { SnapshotEnvironment, SnapshotUpdateState } from '@vitest/snapshot'
import type { SerializedDiffOptions } from '@vitest/utils/diff'
import type { DiffOptions, SerializedDiffOptions } from '@vitest/utils/diff'
import type { LabelColor } from '../types/general'
import type {
SequenceHooks,
SequenceSetupFiles,
SerializableRetry,
TestTagDefinition,
} from './runner/types'
/**
* Config that tests have access to.
*/
export interface SerializedConfig extends VitestRunnerConfig {
export interface SerializedConfig {
root: string
setupFiles: string[]
name: string | undefined
passWithNoTests: boolean
testNamePattern: RegExp | undefined
allowOnly: boolean
sequence: {
shuffle?: boolean
concurrent?: boolean
seed: number
hooks: SequenceHooks
setupFiles: SequenceSetupFiles
}
maxConcurrency: number
testTimeout: number
hookTimeout: number
retry: SerializableRetry
includeTaskLocation: boolean | undefined
tags: TestTagDefinition[]
tagsFilter: string[] | undefined
strictTags: boolean
/**
* @internal
*/
_diffOptions?: DiffOptions
color?: LabelColor
globals: boolean
base: string | undefined
+1 -1
View File
@@ -1,7 +1,7 @@
import type { CancelReason } from '@vitest/runner'
import type { BirpcOptions, BirpcReturn } from 'birpc'
import type { RunnerRPC, RuntimeRPC } from '../types/rpc'
import type { WorkerRPC } from '../types/worker'
import type { CancelReason } from './runner/types'
import { getSafeTimers } from '@vitest/utils/timers'
import { createBirpc } from 'birpc'
import { getWorkerState } from './utils'
+2 -2
View File
@@ -1,10 +1,9 @@
import type { FileSpecification } from '@vitest/runner'
import type { Environment } from '../types/environment'
import type { Traces } from '../utils/traces'
import type { SerializedConfig } from './config'
import type { TestModuleRunner } from './moduleRunner/testModuleRunner'
import type { FileSpecification } from './runner/types'
import { performance } from 'node:perf_hooks'
import { collectTests, startTests } from '@vitest/runner'
import {
startCoverageInsideWorker,
stopCoverageInsideWorker,
@@ -13,6 +12,7 @@ import { resolveSnapshotEnvironment } from '../integrations/snapshot/environment
import { vi } from '../integrations/vi'
import { detectAsyncLeaks } from './detect-async-leaks'
import { closeInspector } from './inspector'
import { collectTests, startTests } from './runner/run'
import { resolveTestRunner } from './runners'
import { setupGlobalEnv } from './setup-node'
import { getWorkerState, resetModules } from './utils'
+2 -2
View File
@@ -1,13 +1,12 @@
import type { FileSpecification } from '@vitest/runner'
import type { Traces } from '../utils/traces'
import type { SerializedConfig } from './config'
import type { TestModuleRunner } from './moduleRunner/testModuleRunner'
import type { FileSpecification } from './runner/types'
import { createRequire } from 'node:module'
import { performance } from 'node:perf_hooks'
import timers from 'node:timers'
import timersPromises from 'node:timers/promises'
import util from 'node:util'
import { collectTests, startTests } from '@vitest/runner'
import { KNOWN_ASSET_TYPES } from '@vitest/utils/constants'
import { setupChaiConfig } from '../integrations/chai/config'
import {
@@ -18,6 +17,7 @@ import { resolveSnapshotEnvironment } from '../integrations/snapshot/environment
import * as VitestIndex from '../public/index'
import { detectAsyncLeaks } from './detect-async-leaks'
import { closeInspector } from './inspector'
import { collectTests, startTests } from './runner/run'
import { resolveTestRunner } from './runners'
import { setupCommonEnv } from './setup-common'
import { getWorkerState } from './utils'
@@ -1,4 +1,4 @@
import type { Test, TestArtifact, TestArtifactBase /* used in JSDoc */, TestAttachment } from './types/tasks'
import type { Test, TestArtifact, TestArtifactBase /* used in JSDoc */, TestAttachment } from './types'
import { finishSendTasksUpdate } from './run'
import { getRunner } from './suite'
import { findTestFileStackTrace } from './utils/collect'
@@ -1,7 +1,12 @@
import type { FileSpecification, VitestRunner } from './types/runner'
import type { File, SuiteHooks } from './types/tasks'
import type { File, FileSpecification, SuiteHooks, VitestRunner } from './types'
import { processError } from '@vitest/utils/error' // TODO: load dynamically
import { toArray } from '@vitest/utils/helpers'
import {
calculateSuiteHash,
createFileTask,
interpretTaskModes,
someTasksAreOnly,
} from '../../utils/tasks'
import { collectorContext } from './context'
import { getHooks, setHooks } from './map'
import { runSetupFiles } from './setup'
@@ -10,12 +15,6 @@ import {
createSuiteHooks,
getDefaultSuite,
} from './suite'
import {
calculateSuiteHash,
createFileTask,
interpretTaskModes,
someTasksAreOnly,
} from './utils/collect'
import { createTagsFilter, validateTags } from './utils/tags'
const now = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now
@@ -1,13 +1,5 @@
import type { Awaitable } from '@vitest/utils'
import type { VitestRunner } from './types/runner'
import type {
RuntimeContext,
SuiteCollector,
Test,
TestAnnotation,
TestContext,
WriteableTestContext,
} from './types/tasks'
import type { RuntimeContext, SuiteCollector, Test, TestAnnotation, TestContext, VitestRunner, WriteableTestContext } from './types'
import { getSafeTimers } from '@vitest/utils/timers'
import { manageArtifactAttachment, recordArtifact, recordAsyncOperation } from './artifact'
import { PendingError } from './errors'
@@ -1,5 +1,4 @@
import type { CancelReason } from './types/runner'
import type { TaskBase } from './types/tasks'
import type { CancelReason, TaskBase } from './types'
export class PendingError extends Error {
public code = 'VITEST_PENDING'
@@ -52,7 +51,7 @@ export class TestSyntaxError extends Error {
super(message)
// use custom property so this survives when the error
// is serialized on `packages/expect` side (e.g. for `expect.soft`)
// and `packages/runner` can still detect it during `test.fails` handling
// and the runner can still detect it during `test.fails` handling
Object.defineProperty(this, '__vitest_test_syntax_error__', {
value: true,
enumerable: false,

Some files were not shown because too many files have changed in this diff Show More