Skip to content

Commit da59eb8

Browse files
authored
fix!: replace deprecated ErrorWithDiff with TestError (#8195)
1 parent ff93444 commit da59eb8

File tree

24 files changed

+59
-84
lines changed

24 files changed

+59
-84
lines changed

docs/advanced/runner.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export interface TaskResult {
238238
* Errors that occurred during the task execution. It is possible to have several errors
239239
* if `expect.soft()` failed multiple times.
240240
*/
241-
errors?: ErrorWithDiff[]
241+
errors?: TestError[]
242242
/**
243243
* How long in milliseconds the task took to run.
244244
*/

packages/browser/src/client/tester/rpc.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,21 @@ import { getSafeTimers } from 'vitest/internal/browser'
44
const { get } = Reflect
55

66
function withSafeTimers(getTimers: typeof getSafeTimers, fn: () => void) {
7-
const { setTimeout, clearTimeout, setImmediate, clearImmediate }
8-
= getTimers()
7+
const { setTimeout, clearTimeout } = getTimers()
98

109
const currentSetTimeout = globalThis.setTimeout
1110
const currentClearTimeout = globalThis.clearTimeout
12-
const currentSetImmediate = globalThis.setImmediate
13-
const currentClearImmediate = globalThis.clearImmediate
1411

1512
try {
1613
globalThis.setTimeout = setTimeout
1714
globalThis.clearTimeout = clearTimeout
18-
globalThis.setImmediate = setImmediate
19-
globalThis.clearImmediate = clearImmediate
2015

2116
const result = fn()
2217
return result
2318
}
2419
finally {
2520
globalThis.setTimeout = currentSetTimeout
2621
globalThis.clearTimeout = currentClearTimeout
27-
globalThis.setImmediate = currentSetImmediate
28-
globalThis.clearImmediate = currentClearImmediate
2922
}
3023
}
3124

packages/browser/src/node/project.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { StackTraceParserOptions } from '@vitest/utils/source-map'
22
import type { ViteDevServer } from 'vite'
3-
import type { ErrorWithDiff, ParsedStack, SerializedConfig } from 'vitest'
3+
import type { ParsedStack, SerializedConfig, TestError } from 'vitest'
44
import type {
55
BrowserProvider,
66
ProjectBrowser as IProjectBrowser,
@@ -93,7 +93,7 @@ export class ProjectBrowser implements IProjectBrowser {
9393
}
9494

9595
public parseErrorStacktrace(
96-
e: ErrorWithDiff,
96+
e: TestError,
9797
options: StackTraceParserOptions = {},
9898
): ParsedStack[] {
9999
return this.parent.parseErrorStacktrace(e, options)

packages/browser/src/node/projectParent.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { StackTraceParserOptions } from '@vitest/utils/source-map'
22
import type { HtmlTagDescriptor } from 'vite'
3-
import type { ErrorWithDiff, ParsedStack } from 'vitest'
3+
import type { ParsedStack, TestError } from 'vitest'
44
import type {
55
BrowserCommand,
66
BrowserScript,
@@ -159,7 +159,7 @@ export class ParentBrowserProject {
159159
}
160160

161161
public parseErrorStacktrace(
162-
e: ErrorWithDiff,
162+
e: TestError,
163163
options: StackTraceParserOptions = {},
164164
): ParsedStack[] {
165165
return parseErrorStacktrace(e, {

packages/browser/src/node/rpc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { MockerRegistry } from '@vitest/mocker'
22
import type { Duplex } from 'node:stream'
3-
import type { ErrorWithDiff } from 'vitest'
3+
import type { TestError } from 'vitest'
44
import type { BrowserCommandContext, ResolveSnapshotPathHandlerContext, TestProject } from 'vitest/node'
55
import type { WebSocket } from 'ws'
66
import type { ParentBrowserProject } from './projectParent'
@@ -128,7 +128,7 @@ export function setupBrowserRpc(globalServer: ParentBrowserProject, defaultMocke
128128
{
129129
async onUnhandledError(error, type) {
130130
if (error && typeof error === 'object') {
131-
const _error = error as ErrorWithDiff
131+
const _error = error as TestError
132132
_error.stacks = globalServer.parseErrorStacktrace(_error)
133133
}
134134
vitest.state.catchError(error, type)

packages/runner/src/types/tasks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Awaitable, ErrorWithDiff } from '@vitest/utils'
1+
import type { Awaitable, TestError } from '@vitest/utils'
22
import type { FixtureItem } from '../fixture'
33
import type { ChainableFunction } from '../utils/chain'
44

@@ -118,7 +118,7 @@ export interface TaskResult {
118118
* Errors that occurred during the task execution. It is possible to have several errors
119119
* if `expect.soft()` failed multiple times or `retry` was triggered.
120120
*/
121-
errors?: ErrorWithDiff[]
121+
errors?: TestError[]
122122
/**
123123
* How long in milliseconds the task took to run.
124124
*/

packages/ui/client/components/dashboard/ErrorEntry.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script setup lang="ts">
2-
import type { ErrorWithDiff } from '@vitest/utils'
2+
import type { TestError } from '@vitest/utils'
33
44
defineProps<{
5-
error: ErrorWithDiff
5+
error: TestError
66
}>()
77
</script>
88

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import type { Task } from '@vitest/runner'
33
import type CodeMirror from 'codemirror'
4-
import type { ErrorWithDiff, File, TestAnnotation, TestError } from 'vitest'
4+
import type { File, TestAnnotation, TestError } from 'vitest'
55
import { createTooltip, destroyTooltip } from 'floating-vue'
66
import { getAttachmentUrl, sanitizeFilePath } from '~/composables/attachments'
77
import { client, isReport } from '~/composables/client'
@@ -144,7 +144,7 @@ watch(
144144
{ immediate: true },
145145
)
146146
147-
function createErrorElement(e: ErrorWithDiff) {
147+
function createErrorElement(e: TestError) {
148148
const stacks = (e?.stacks || []).filter(
149149
i => i.file && i.file === props.file?.filepath,
150150
)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import type { ErrorWithDiff, ParsedStack } from 'vitest'
2+
import type { ParsedStack, TestError } from 'vitest'
33
import { showLocationSource } from '~/composables/codemirror'
44
import { isTestFile, openInEditor } from '~/composables/error'
55
import { escapeHtml } from '~/utils/escape'
@@ -8,7 +8,7 @@ const props = defineProps<{
88
fileId: string
99
root: string
1010
filename?: string
11-
error: ErrorWithDiff
11+
error: TestError
1212
}>()
1313
1414
function relative(p: string) {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { ErrorWithDiff } from '@vitest/utils'
1+
import type { TestError } from '@vitest/utils'
22
import type { Ref } from 'vue'
33
import type { RunState } from '../../../types'
44

55
export const testRunState: Ref<RunState> = ref('idle')
66
export const finished = computed(() => testRunState.value === 'idle')
7-
export const unhandledErrors: Ref<ErrorWithDiff[]> = ref([])
7+
export const unhandledErrors: Ref<TestError[]> = ref([])

0 commit comments

Comments
 (0)