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

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

Open
eliasm307 opened this issue Oct 18, 2024 · 2 comments

Comments

@eliasm307
Copy link

🚀 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

Copy link

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.

@github-actions github-actions bot added Stale and removed Stale labels Nov 17, 2024
@eliasm307
Copy link
Author

Commenting to keep active, pending feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant