Skip to content

Commit 46fc534

Browse files
committed
fix: don't use Custom internally
1 parent aa1dac3 commit 46fc534

File tree

16 files changed

+44
-56
lines changed

16 files changed

+44
-56
lines changed

packages/runner/src/collect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export async function collectTests(
6060
mergeHooks(fileHooks, getHooks(defaultTasks))
6161

6262
for (const c of [...defaultTasks.tasks, ...collectorContext.tasks]) {
63-
if (c.type === 'test' || c.type === 'custom' || c.type === 'suite') {
63+
if (c.type === 'test' || c.type === 'suite') {
6464
file.tasks.push(c)
6565
}
6666
else if (c.type === 'collector') {

packages/runner/src/run.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type { Awaitable } from '@vitest/utils'
22
import type { DiffOptions } from '@vitest/utils/diff'
33
import type { FileSpec, VitestRunner } from './types/runner'
44
import type {
5-
Custom,
65
File,
76
HookCleanupCallback,
87
HookListener,
@@ -177,7 +176,7 @@ async function callCleanupHooks(cleanups: HookCleanupCallback[]) {
177176
)
178177
}
179178

180-
export async function runTest(test: Test | Custom, runner: VitestRunner): Promise<void> {
179+
export async function runTest(test: Test, runner: VitestRunner): Promise<void> {
181180
await runner.onBeforeRunTask?.(test)
182181

183182
if (test.mode !== 'run') {
@@ -471,7 +470,7 @@ export async function runSuite(suite: Suite, runner: VitestRunner): Promise<void
471470
let limitMaxConcurrency: ReturnType<typeof limitConcurrency>
472471

473472
async function runSuiteChild(c: Task, runner: VitestRunner) {
474-
if (c.type === 'test' || c.type === 'custom') {
473+
if (c.type === 'test') {
475474
return limitMaxConcurrency(() => runTest(c, runner))
476475
}
477476
else if (c.type === 'suite') {

packages/runner/src/suite.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { FixtureItem } from './fixture'
22
import type { VitestRunner } from './types/runner'
33
import type {
4-
Custom,
54
CustomAPI,
65
File,
76
Fixtures,
@@ -294,7 +293,7 @@ function createSuiteCollector(
294293
each?: boolean,
295294
suiteOptions?: TestOptions,
296295
) {
297-
const tasks: (Test | Custom | Suite | SuiteCollector)[] = []
296+
const tasks: (Test | Suite | SuiteCollector)[] = []
298297
const factoryQueue: (Test | Suite | SuiteCollector)[] = []
299298

300299
let suite: Suite

packages/runner/src/test-state.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import type { Custom, Test } from './types/tasks.ts'
1+
import type { Test } from './types/tasks.ts'
22

3-
let _test: Test | Custom | undefined
3+
let _test: Test | undefined
44

5-
export function setCurrentTest<T extends Test | Custom>(test: T | undefined): void {
5+
export function setCurrentTest<T extends Test>(test: T | undefined): void {
66
_test = test
77
}
88

9-
export function getCurrentTest<T extends Test | Custom | undefined>(): T {
9+
export function getCurrentTest<T extends Test | undefined>(): T {
1010
return _test as T
1111
}

packages/runner/src/types/runner.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { DiffOptions } from '@vitest/utils/diff'
22
import type {
3-
Custom,
43
ExtendedContext,
54
File,
65
SequenceHooks,
@@ -91,7 +90,7 @@ export interface VitestRunner {
9190
/**
9291
* When the task has finished running, but before cleanup hooks are called
9392
*/
94-
onTaskFinished?: (test: Test | Custom) => unknown
93+
onTaskFinished?: (test: Test) => unknown
9594
/**
9695
* Called after result and state are set.
9796
*/

packages/runner/src/types/tasks.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ export interface Custom<ExtraContext = object> extends TaskPopulated {
234234
context: TaskContext<Test> & ExtraContext & TestContext
235235
}
236236

237-
export type Task = Test | Suite | Custom | File
237+
export type Task = Test | Suite | File
238238

239239
/**
240240
* @deprecated Vitest doesn't provide `done()` anymore
@@ -578,8 +578,6 @@ export interface SuiteCollector<ExtraContext = object> {
578578
test: TestAPI<ExtraContext>
579579
tasks: (
580580
| Suite
581-
// TODO: remove in Vitest 3
582-
| Custom<ExtraContext>
583581
| Test<ExtraContext>
584582
| SuiteCollector<ExtraContext>
585583
)[]

packages/runner/src/utils/tasks.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import type { Custom, Suite, Task, Test } from '../types/tasks'
1+
import type { Suite, Task, Test } from '../types/tasks'
22
import { type Arrayable, toArray } from '@vitest/utils'
33

44
/**
55
* @deprecated use `isTestCase` instead
66
*/
7-
export function isAtomTest(s: Task): s is Test | Custom {
7+
export function isAtomTest(s: Task): s is Test {
88
return isTestCase(s)
99
}
1010

11-
export function isTestCase(s: Task): s is Test | Custom {
12-
return s.type === 'test' || s.type === 'custom'
11+
export function isTestCase(s: Task): s is Test {
12+
return s.type === 'test'
1313
}
1414

15-
export function getTests(suite: Arrayable<Task>): (Test | Custom)[] {
16-
const tests: (Test | Custom)[] = []
15+
export function getTests(suite: Arrayable<Task>): Test[] {
16+
const tests: Test[] = []
1717
const arraySuites = toArray(suite)
1818
for (const s of arraySuites) {
1919
if (isTestCase(s)) {

packages/ui/client/components/views/ViewReport.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function collectFailed(task: Task, level: number): LeveledTask[] {
1919
return []
2020
}
2121
22-
if (task.type === 'test' || task.type === 'custom') {
22+
if (task.type === 'test') {
2323
return [{ ...task, level }]
2424
}
2525
else {

packages/ui/client/composables/explorer/collector.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { Custom, File, Task, TaskResultPack, Test } from '@vitest/runner'
1+
import type { File, Task, TaskResultPack, Test } from '@vitest/runner'
22
import type { Arrayable } from '@vitest/utils'
33
import type { CollectFilteredTests, CollectorInfo, Filter, FilteredTests } from '~/composables/explorer/types'
4-
import { isAtomTest } from '@vitest/runner/utils'
4+
import { isTestCase } from '@vitest/runner/utils/tasks'
55
import { toArray } from '@vitest/utils'
66
import { hasFailedSnapshot } from '@vitest/ws-client'
77
import { client, findById } from '~/composables/client'
@@ -460,12 +460,12 @@ export function collectTestsTotalData(
460460
return filesSummary
461461
}
462462

463-
function* testsCollector(suite: Arrayable<Task>): Generator<Test | Custom> {
463+
function* testsCollector(suite: Arrayable<Task>): Generator<Test> {
464464
const arraySuites = toArray(suite)
465465
let s: Task
466466
for (let i = 0; i < arraySuites.length; i++) {
467467
s = arraySuites[i]
468-
if (isAtomTest(s)) {
468+
if (isTestCase(s)) {
469469
yield s
470470
}
471471
else {

packages/ui/client/composables/explorer/types.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface RootTreeNode extends TaskTreeNode {
2525
tasks: FileTreeNode[]
2626
}
2727

28-
export type TaskTreeNodeType = 'file' | 'suite' | 'test' | 'custom'
28+
export type TaskTreeNodeType = 'file' | 'suite' | 'test'
2929

3030
export interface UITaskTreeNode extends TaskTreeNode {
3131
type: TaskTreeNodeType
@@ -42,11 +42,6 @@ export interface TestTreeNode extends UITaskTreeNode {
4242
type: 'test'
4343
}
4444

45-
export interface CustomTestTreeNode extends UITaskTreeNode {
46-
fileId: string
47-
type: 'custom'
48-
}
49-
5045
export interface ParentTreeNode extends UITaskTreeNode {
5146
children: Set<string>
5247
tasks: UITaskTreeNode[]

0 commit comments

Comments
 (0)