[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

Revert "fix: respect diff config options in soft assertions (#8696)"

This reverts commit 9787dedade9896a6d3eeed7739177d6c583a68a7.

Vladimir Sheremet (Apr 21, 2026, 12:59 PM +0200) 7dc6d54f 9787deda

+1 -83
+1 -2
packages/expect/src/utils.ts
··· 89 89 test.result ||= { state: 'fail' } 90 90 test.result.state = 'fail' 91 91 test.result.errors ||= [] 92 - const diffOptions = (globalThis as any).__vitest_worker__?.diffOptions 93 - test.result.errors.push(processError(err, diffOptions)) 92 + test.result.errors.push(processError(err)) 94 93 } 95 94 96 95 /** wrap assertion function to support `expect.soft` and provide assertion name as `_name` */
-31
test/config/test/diff.test.ts
··· 17 17 errors.map(e => e.diff && stripVTControlCharacters(e.diff)), 18 18 ).matchSnapshot() 19 19 }) 20 - 21 - test('soft assertion with printBasicPrototype diff option', async () => { 22 - const { ctx } = await runVitest({ 23 - root: './fixtures/diff', 24 - diff: { printBasicPrototype: true }, 25 - }, ['soft-assertions.test.ts']) 26 - 27 - const errors = ctx!.state.getFiles().flatMap(f => 28 - f.tasks.flatMap(t => t.result?.errors ?? []), 29 - ) 30 - 31 - expect(errors.length).toBeGreaterThan(0) 32 - 33 - const diff = errors[0].diff && stripVTControlCharacters(errors[0].diff) 34 - expect(diff).toMatchInlineSnapshot(` 35 - "- Expected 36 - + Received 37 - 38 - Object { 39 - "arr": Array [ 40 - 1, 41 - - 3, 42 - + 2, 43 - ], 44 - "obj": Object { 45 - - "k": "bar", 46 - + "k": "foo", 47 - }, 48 - }" 49 - `) 50 - })
-2
packages/vitest/src/types/worker.ts
··· 1 1 import type { CancelReason, FileSpecification, Task } from '@vitest/runner' 2 - import type { SerializedDiffOptions } from '@vitest/utils/diff' 3 2 import type { BirpcReturn } from 'birpc' 4 3 import type { EvaluatedModules } from 'vite/module-runner' 5 4 import type { SerializedConfig } from '../runtime/config' ··· 83 82 prepare: number 84 83 } 85 84 onFilterStackTrace?: (trace: string) => string 86 - diffOptions?: SerializedDiffOptions 87 85 }
-15
test/config/fixtures/diff/soft-assertions.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - test('soft assertion with custom diff options', () => { 4 - const obj1 = { 5 - obj: { k: 'foo' }, 6 - arr: [1, 2], 7 - } 8 - const obj2 = { 9 - obj: { k: 'bar' }, 10 - arr: [1, 3], 11 - } 12 - 13 - // Use soft assertion to ensure error processing goes through handleTestError 14 - expect.soft(obj1).toEqual(obj2) 15 - })
-28
test/config/test/__snapshots__/diff.test.ts.snap
··· 54 54 + "k": "foo", 55 55 }, 56 56 }", 57 - "- Expected 58 - + Received 59 - 60 - { 61 - "arr": [ 62 - 1, 63 - - 3, 64 - + 2, 65 - ], 66 - "obj": { 67 - - "k": "bar", 68 - + "k": "foo", 69 - }, 70 - }", 71 57 ] 72 58 `; 73 59 ··· 107 93 - 3000, 108 94 + 29, 109 95 ]", 110 - "- Expected 111 - + Received 112 - 113 - Object { 114 - "arr": Array [ 115 - 1, 116 - - 3, 117 - + 2, 118 - ], 119 - "obj": Object { 120 - - "k": "bar", 121 - + "k": "foo", 122 - }, 123 - }", 124 96 "- Expected 125 97 + Received 126 98
-5
packages/vitest/src/runtime/runners/index.ts
··· 62 62 ]) 63 63 testRunner.config.diffOptions = diffOptions 64 64 65 - // Store diffOptions in the global worker state so they're accessible 66 - // to packages that can't directly import from @vitest/runner (e.g., @vitest/expect) 67 - const workerState = getWorkerState() 68 - workerState.diffOptions = diffOptions 69 - 70 65 // patch some methods, so custom runners don't need to call RPC 71 66 const originalOnTaskUpdate = testRunner.onTaskUpdate 72 67 testRunner.onTaskUpdate = async (task, events) => {