jestjs/jest

[Feature]: [pretty-format] make it easier to copy-paste the output of an assertion failure to JS again

eliasm307 opened this issue ยท 4 comments

๐Ÿš€ Feature Proposal

Similar to #10730 this is a request for assertion output to not include the "Array" and "Object" names from assertion output diff

Motivation

Instead of using toMatchInlineSnapshot I use the regular value assertions e.g. toEqual and in some cases where I know some current behaviour is correct, I run the test with an empty value e.g. an empty object or something, then copy the assertion failure diff as the new expectation.

The issue is that the assertion failure diff requires formatting, e.g. removing the "+" characters, which is acceptable, but in some cases I also need to remove the inline prototype names that are added.

It would be good if there was an option like exists for snapshots to turn this off for some values in the same way as done in #10730

Example

From this assertion

    expect({
      obj: { foo: 'bar' },
      array: [1, 2, 3],
      set: new Set([1, 2, 3]),
    }).toEqual({});

the output is:

image

the "Set" is acceptable, but ideally an option for "Object" and "Array" to not be shown would be good

Pitch

For similar reasons #10730 was added

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

Commenting to keep active, pending feedback

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

Commenting to keep active, pending feedback