Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/ui/client/components/views/ViewReport.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { File } from 'vitest'
import type { RunnerTestFile } from 'vitest'
import { faker } from '@faker-js/faker'
import { beforeEach, describe, expect, it } from 'vitest'
import { config } from '~/composables/client'
Expand Down Expand Up @@ -42,7 +42,7 @@ const error = {
diff,
}

const fileWithTextStacks: File = {
const fileWithTextStacks: RunnerTestFile = {
id: 'f-1',
name: 'test/plain-stack-trace.ts',
type: 'suite',
Expand All @@ -60,7 +60,7 @@ const fileWithTextStacks: File = {
fileWithTextStacks.file = fileWithTextStacks

describe('ViewReport', () => {
describe('File where stacks are in text', () => {
describe('RunnerTestFile where stacks are in text', () => {
beforeEach(() => {
render(ViewReport, {
props: {
Expand Down Expand Up @@ -92,7 +92,7 @@ describe('ViewReport', () => {
})

it('test html stack trace without html message', () => {
const file: File = {
const file: RunnerTestFile = {
id: 'f-1',
name: 'test/plain-stack-trace.ts',
type: 'suite',
Expand Down Expand Up @@ -150,7 +150,7 @@ describe('ViewReport', () => {
})

it('test html stack trace and message', () => {
const file: File = {
const file: RunnerTestFile = {
id: 'f-1',
name: 'test/plain-stack-trace.ts',
type: 'suite',
Expand Down
21 changes: 14 additions & 7 deletions packages/ui/client/composables/client/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import type { WebSocketStatus } from '@vueuse/core'
import type { File, RunnerTaskEventPack, SerializedConfig, Task, TaskResultPack, TestAnnotation } from 'vitest'
import type {
RunnerTask,
RunnerTaskEventPack,
RunnerTaskResultPack,
RunnerTestFile,
SerializedConfig,
TestAnnotation,
} from 'vitest'
import type { BrowserRunnerState } from '../../../types'
import { createFileTask } from '@vitest/runner/utils'
import { createClient, getTasks } from '@vitest/ws-client'
Expand Down Expand Up @@ -29,7 +36,7 @@ export const client = (function createVitestClient() {
onTestAnnotate(testId: string, annotation: TestAnnotation) {
explorerTree.annotateTest(testId, annotation)
},
onTaskUpdate(packs: TaskResultPack[], events: RunnerTaskEventPack[]) {
onTaskUpdate(packs: RunnerTaskResultPack[], events: RunnerTaskEventPack[]) {
explorerTree.resumeRun(packs, events)
testRunState.value = 'running'
},
Expand Down Expand Up @@ -65,7 +72,7 @@ export const currentLogs = computed(() => getTasks(current.value).map(i => i?.lo

export function findById(id: string) {
const file = client.state.idMap.get(id)
return file ? file as File : undefined
return file ? file as RunnerTestFile : undefined
}

export const isConnected = computed(() => status.value === 'OPEN')
Expand All @@ -76,7 +83,7 @@ export function runAll() {
return runFiles(client.state.getFiles())
}

function clearTaskResult(task: Task) {
function clearTaskResult(task: RunnerTask) {
delete task.result
const node = explorerTree.nodes.get(task.id)
if (node) {
Expand All @@ -90,7 +97,7 @@ function clearTaskResult(task: Task) {
}
}

function clearResults(useFiles: File[]) {
function clearResults(useFiles: RunnerTestFile[]) {
const map = explorerTree.nodes
useFiles.forEach((f) => {
delete f.result
Expand All @@ -115,15 +122,15 @@ function clearResults(useFiles: File[]) {
})
}

export function runFiles(useFiles: File[]) {
export function runFiles(useFiles: RunnerTestFile[]) {
clearResults(useFiles)

explorerTree.startRun()

return client.rpc.rerun(useFiles.map(i => i.filepath), true)
}

export function runTask(task: Task) {
export function runTask(task: RunnerTask) {
clearTaskResult(task)

explorerTree.startRun()
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/client/composables/client/static.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { VitestClient } from '@vitest/ws-client'
import type { BirpcReturn } from 'birpc'
import type {
File,
ModuleGraphData,
RunnerTestFile,
SerializedConfig,
WebSocketEvents,
WebSocketHandlers,
Expand All @@ -13,7 +13,7 @@ import { StateManager } from '../../../../ws-client/src/state'

interface HTMLReportMetadata {
paths: string[]
files: File[]
files: RunnerTestFile[]
config: SerializedConfig
projects: string[]
moduleGraph: Record<string, Record<string, ModuleGraphData>>
Expand Down
6 changes: 3 additions & 3 deletions packages/ui/client/utils/task.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Suite, Task } from 'vitest'
import type { RunnerTask, RunnerTestSuite } from 'vitest'

export function isSuite(task: Task): task is Suite {
export function isSuite(task: RunnerTask): task is RunnerTestSuite {
return Object.hasOwnProperty.call(task, 'tasks')
}

export function isTaskDone(task: Task) {
export function isTaskDone(task: RunnerTask) {
const state = task.result?.state
const mode = task.mode

Expand Down
52 changes: 0 additions & 52 deletions packages/vitest/src/public/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
import type {
Custom as Custom_,
DoneCallback as DoneCallback_,
File as File_,
Suite as Suite_,
Task as Task_,
TaskBase as TaskBase_,
TaskResult as TaskResult_,
TaskResultPack as TaskResultPack_,
Test as Test_,
} from '@vitest/runner'
import type {
/** @deprecated import from `vitest/node` instead */
Vitest as Vitest_,
Expand Down Expand Up @@ -53,14 +42,6 @@ import type {

import type { SerializedTestSpecification } from '../runtime/types/utils'

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 {
WorkerRPC as WorkerRPC_,
} from '../types/worker'
Expand Down Expand Up @@ -100,39 +81,6 @@ export type {
} from '../runtime/types/benchmark'
export { 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_

/** @deprecated use `RunnerTestSuite` instead */
export type Suite = Suite_
/** @deprecated use `RunnerTestFile` instead */
export type File = File_
/** @deprecated use `RunnerTestCase` instead */
export type Test = Test_
/** @deprecated do not use `Custom`, use `RunnerTestCase` instead */
export type Custom = Custom_
/** @deprecated use `RunnerTask` instead */
export type Task = Task_
/** @deprecated use `RunnerTaskBase` instead */
export type TaskBase = TaskBase_
/** @deprecated use `RunnerTaskResult` instead */
export type TaskResult = TaskResult_
/** @deprecated use `RunnerTaskResultPack` instead */
export type TaskResultPack = TaskResultPack_

/** @deprecated don't use `DoneCallback` since it's not supported */
export type DoneCallback = DoneCallback_

export type { AssertType } from '../typecheck/assertType'
export { expectTypeOf } from '../typecheck/expectTypeOf'
export type { ExpectTypeOf } from '../typecheck/expectTypeOf'
Expand Down
4 changes: 2 additions & 2 deletions test/reporters/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Vitest } from '../../../packages/vitest/src/node/core'
import type { Logger } from '../../../packages/vitest/src/node/logger'
import type { StateManager } from '../../../packages/vitest/src/node/state'
import type { ResolvedConfig } from '../../../packages/vitest/src/node/types/config'
import type { File } from '../../../packages/vitest/src/public/index'
import type { RunnerTestFile } from '../../../packages/vitest/src/public/index'

interface Context {
vitest: Vitest
Expand All @@ -26,7 +26,7 @@ export function getContext(): Context {
}

const state: Partial<StateManager> = {
filesMap: new Map<string, File[]>(),
filesMap: new Map<string, RunnerTestFile[]>(),
}

const context: Partial<Vitest> = {
Expand Down
6 changes: 3 additions & 3 deletions test/reporters/src/data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Suite, Task, TestError } from 'vitest'
import type { RunnerTestCase, RunnerTestSuite, TestError } from 'vitest'
import { createFileTask } from '@vitest/runner/utils'

const file = createFileTask(
Expand All @@ -12,7 +12,7 @@ file.result = {
duration: 145.99284195899963,
}

const suite: Suite = {
const suite: RunnerTestSuite = {
id: `${file.id}_0`,
type: 'suite',
name: 'suite',
Expand Down Expand Up @@ -68,7 +68,7 @@ error.stack = 'AssertionError: expected 2.23606797749979 to equal 2\n'
+ ' at async run (/vitest/packages/vitest/dist/entry.js:1797:5)\n'
+ ' at async file:///vitest/node_modules/.pnpm/[email protected]/node_modules/tinypool/dist/esm/worker.js:96:20'

const tasks: Task[] = [
const tasks: RunnerTestCase[] = [
{
id: `${suite.id}_0`,
type: 'test',
Expand Down
10 changes: 5 additions & 5 deletions test/reporters/tests/junit.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { File, Suite, Task, TaskResult } from 'vitest'
import type { RunnerTaskResult, RunnerTestCase, RunnerTestFile, RunnerTestSuite } from 'vitest'
import { createFileTask } from '@vitest/runner/utils'
import { resolve } from 'pathe'
import { expect, test } from 'vitest'
Expand All @@ -8,9 +8,9 @@ import { runVitest, runVitestCli } from '../../test-utils'
const root = resolve(__dirname, '../fixtures')

test('calc the duration used by junit', () => {
const result: TaskResult = { state: 'pass', duration: 0 }
const file: File = createFileTask('/test.ts', '/', 'test')
const suite: Suite = {
const result: RunnerTaskResult = { state: 'pass', duration: 0 }
const file: RunnerTestFile = createFileTask('/test.ts', '/', 'test')
const suite: RunnerTestSuite = {
id: '1_0',
type: 'suite',
name: 'suite',
Expand All @@ -19,7 +19,7 @@ test('calc the duration used by junit', () => {
file,
meta: {},
}
const task: Task = {
const task: RunnerTestCase = {
id: '1_0_0',
type: 'test',
name: 'timeout',
Expand Down
Loading