Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: diff.printBasicPrototype: false by default #7043

Merged
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
2 changes: 1 addition & 1 deletion docs/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2507,7 +2507,7 @@ Color of truncate annotation, default is output with no color.
#### diff.printBasicPrototype

- **Type**: `boolean`
- **Default**: `true`
- **Default**: `false`

Print basic prototype `Object` and `Array` in diff output

Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/diff/normalizeDiffOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function getDefaultOptions(): DiffOptionsNormalized {
includeChangeCounts: false,
omitAnnotationLines: false,
patchColor: c.yellow,
printBasicPrototype: true,
printBasicPrototype: false,
truncateThreshold: DIFF_TRUNCATE_THRESHOLD_DEFAULT,
truncateAnnotation: '... Diff result is truncated',
truncateAnnotationColor: noColor,
Expand Down
18 changes: 9 additions & 9 deletions test/config/test/__snapshots__/diff.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`inline diff options: { expand: false, printBasicPrototype: false } 1`] = `
exports[`inline diff options: { expand: false, printBasicPrototype: true } 1`] = `
[
"- Expected
+ Received

@@ -1,7 +1,7 @@
[
Array [
- 1000,
+ 0,
1,
Expand Down Expand Up @@ -39,13 +39,13 @@ exports[`inline diff options: { expand: false, printBasicPrototype: false } 1`]
"- Expected
+ Received

{
"arr": [
Object {
"arr": Array [
1,
- 3,
+ 2,
],
"obj": {
"obj": Object {
- "k": "bar",
+ "k": "foo",
},
Expand All @@ -58,7 +58,7 @@ exports[`inline diff options: undefined 1`] = `
"- Expected
+ Received

Array [
[
- 1000,
+ 0,
1,
Expand Down Expand Up @@ -96,13 +96,13 @@ exports[`inline diff options: undefined 1`] = `
"- Expected
+ Received

Object {
"arr": Array [
{
"arr": [
1,
- 3,
+ 2,
],
"obj": Object {
"obj": {
- "k": "bar",
+ "k": "foo",
},
Expand Down
2 changes: 1 addition & 1 deletion test/config/test/diff.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { runVitest } from '../../test-utils'

test.for([
[undefined],
[{ expand: false, printBasicPrototype: false }],
[{ expand: false, printBasicPrototype: true }],
])(`inline diff options: %o`, async ([options]) => {
const { ctx } = await runVitest({
root: './fixtures/diff',
Expand Down
22 changes: 11 additions & 11 deletions test/core/test/__snapshots__/jest-expect.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ exports[`asymmetric matcher error 3`] = `
"diff": "- Expected
+ Received

Object {
{
- "foo": StringContaining "xx",
+ "foo": "hello",
}",
Expand All @@ -45,7 +45,7 @@ exports[`asymmetric matcher error 4`] = `
"diff": "- Expected
+ Received

Object {
{
- "foo": StringNotContaining "ll",
+ "foo": "hello",
}",
Expand Down Expand Up @@ -90,7 +90,7 @@ exports[`asymmetric matcher error 7`] = `
"diff": "- Expected
+ Received

Object {
{
- "foo": stringContainingCustom<xx>,
+ "foo": "hello",
}",
Expand All @@ -109,7 +109,7 @@ exports[`asymmetric matcher error 8`] = `
"diff": "- Expected
+ Received

Object {
{
- "foo": not.stringContainingCustom<ll>,
+ "foo": "hello",
}",
Expand Down Expand Up @@ -161,7 +161,7 @@ exports[`asymmetric matcher error 12`] = `
+ Received

- ObjectContaining {
+ Object {
+ {
"k": "v",
- "k3": "v3",
+ "k2": "v2",
Expand All @@ -184,7 +184,7 @@ exports[`asymmetric matcher error 13`] = `
+ Received

- ArrayContaining [
+ Array [
+ [
"a",
- "c",
+ "b",
Expand Down Expand Up @@ -333,7 +333,7 @@ exports[`diff 2`] = `
false

+ Received:
Object {
{
"hello": "world",
}",
"expected": "false",
Expand All @@ -350,7 +350,7 @@ exports[`diff 3`] = `
NaN

+ Received:
Object {
{
"hello": "world",
}",
"expected": "NaN",
Expand All @@ -367,7 +367,7 @@ exports[`diff 4`] = `
undefined

+ Received:
Object {
{
"hello": "world",
}",
"expected": "undefined",
Expand All @@ -384,7 +384,7 @@ exports[`diff 5`] = `
null

+ Received:
Object {
{
"hello": "world",
}",
"expected": "null",
Expand All @@ -400,7 +400,7 @@ exports[`toHaveBeenNthCalledWith error 1`] = `
"diff": "- Expected
+ Received

Array [
[
- "hey",
+ "Hi",
]",
Expand Down
6 changes: 3 additions & 3 deletions test/core/test/__snapshots__/mocked.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@ Received:

1st spy call return:

Object {
{
- "a": "4",
+ "a": "1",
}

2nd spy call return:

Object {
{
- "a": "4",
+ "a": "1",
}

3rd spy call return:

Object {
{
- "a": "4",
+ "a": "1",
}
Expand Down
28 changes: 14 additions & 14 deletions test/core/test/diff.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test('displays object diff', () => {
- Expected
+ Received

Object {
{
"a": 1,
- "b": 2,
+ "b": 3,
Expand All @@ -47,7 +47,7 @@ test('display truncated object diff', () => {
- Expected
+ Received

Object {
{
"a": 1,
- "b": 2,
- "c": 3,
Expand Down Expand Up @@ -137,7 +137,7 @@ test('display truncated multiple items array diff', () => {
- Expected
+ Received

Array [
[
- "foo",
- "foo",
+ "bar",
Expand All @@ -152,7 +152,7 @@ test('asymmetric matcher in object', () => {
"- Expected
+ Received

Object {
{
- "x": 1,
+ "x": 0,
"y": Anything,
Expand All @@ -171,7 +171,7 @@ test('asymmetric matcher in object with truncated diff', () => {
"- Expected
+ Received

Object {
{
"w": Anything,
- "x": 1,
+ "x": 0,
Expand All @@ -184,7 +184,7 @@ test('asymmetric matcher in array', () => {
"- Expected
+ Received

Array [
[
- 1,
+ 0,
Anything,
Expand All @@ -203,7 +203,7 @@ test('asymmetric matcher in array with truncated diff', () => {
"- Expected
+ Received

Array [
[
- 1,
+ 0,
... Diff result is truncated"
Expand All @@ -220,13 +220,13 @@ test('asymmetric matcher in nested', () => {
"- Expected
+ Received

Array [
Object {
[
{
- "x": 1,
+ "x": 0,
"y": Anything,
},
Array [
[
- 1,
+ 0,
Anything,
Expand All @@ -246,8 +246,8 @@ test('asymmetric matcher in nested with truncated diff', () => {
"- Expected
+ Received

Array [
Object {
[
{
- "x": 1,
+ "x": 0,
"y": Anything,
Expand Down Expand Up @@ -321,8 +321,8 @@ test('getter only property', () => {
"- Expected
+ Received

Object {
"getOnlyProp": Object {
{
"getOnlyProp": {
"a": "b",
},
- "normalProp": 2,
Expand Down
Loading
Loading