Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7dc6d54

Browse filesBrowse files
committed
Revert "fix: respect diff config options in soft assertions (#8696)"
This reverts commit 9787ded.
1 parent 9787ded commit 7dc6d54
Copy full SHA for 7dc6d54

6 files changed

+1-83Lines changed: 1 addition & 83 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/expect/src/utils.ts‎

Copy file name to clipboardExpand all lines: packages/expect/src/utils.ts
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ function handleTestError(test: Test, err: unknown) {
8989
test.result ||= { state: 'fail' }
9090
test.result.state = 'fail'
9191
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))
9493
}
9594

9695
/** wrap assertion function to support `expect.soft` and provide assertion name as `_name` */
Collapse file

‎packages/vitest/src/runtime/runners/index.ts‎

Copy file name to clipboardExpand all lines: packages/vitest/src/runtime/runners/index.ts
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ export async function resolveTestRunner(
6262
])
6363
testRunner.config.diffOptions = diffOptions
6464

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-
7065
// patch some methods, so custom runners don't need to call RPC
7166
const originalOnTaskUpdate = testRunner.onTaskUpdate
7267
testRunner.onTaskUpdate = async (task, events) => {
Collapse file

‎packages/vitest/src/types/worker.ts‎

Copy file name to clipboardExpand all lines: packages/vitest/src/types/worker.ts
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { CancelReason, FileSpecification, Task } from '@vitest/runner'
2-
import type { SerializedDiffOptions } from '@vitest/utils/diff'
32
import type { BirpcReturn } from 'birpc'
43
import type { EvaluatedModules } from 'vite/module-runner'
54
import type { SerializedConfig } from '../runtime/config'
@@ -83,5 +82,4 @@ export interface WorkerGlobalState {
8382
prepare: number
8483
}
8584
onFilterStackTrace?: (trace: string) => string
86-
diffOptions?: SerializedDiffOptions
8785
}
Collapse file

‎test/config/fixtures/diff/soft-assertions.test.ts‎

Copy file name to clipboardExpand all lines: test/config/fixtures/diff/soft-assertions.test.ts
-15Lines changed: 0 additions & 15 deletions
This file was deleted.
Collapse file

‎test/config/test/__snapshots__/diff.test.ts.snap‎

Copy file name to clipboardExpand all lines: test/config/test/__snapshots__/diff.test.ts.snap
-28Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,6 @@ exports[`inline diff options: { expand: true } 1`] = `
5151
],
5252
"obj": {
5353
- "k": "bar",
54-
+ "k": "foo",
55-
},
56-
}",
57-
"- Expected
58-
+ Received
59-
60-
{
61-
"arr": [
62-
1,
63-
- 3,
64-
+ 2,
65-
],
66-
"obj": {
67-
- "k": "bar",
6854
+ "k": "foo",
6955
},
7056
}",
@@ -118,20 +104,6 @@ exports[`inline diff options: { printBasicPrototype: true } 1`] = `
118104
],
119105
"obj": Object {
120106
- "k": "bar",
121-
+ "k": "foo",
122-
},
123-
}",
124-
"- Expected
125-
+ Received
126-
127-
Object {
128-
"arr": Array [
129-
1,
130-
- 3,
131-
+ 2,
132-
],
133-
"obj": Object {
134-
- "k": "bar",
135107
+ "k": "foo",
136108
},
137109
}",
Collapse file

‎test/config/test/diff.test.ts‎

Copy file name to clipboardExpand all lines: test/config/test/diff.test.ts
-31Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,3 @@ test.for([
1717
errors.map(e => e.diff && stripVTControlCharacters(e.diff)),
1818
).matchSnapshot()
1919
})
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-
})

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.