vitest icon indicating copy to clipboard operation
vitest copied to clipboard

Don't expand large diffs by default

Open remorses opened this issue 2 years ago • 3 comments

Clear and concise description of the problem

Calling toEqual on large objects generates a very large diff error difficult to understand and often cut by the max terminal output length, this can be prevented by passing expand: false to the diff function

Suggested solution

Pass expand: false for large objects and strings

Alternative

Add an expand option in the vitest configuration or always use expand false

Additional context

No response

Validations

remorses avatar Oct 28 '23 15:10 remorses

what is the supposed workaround right now? killing my productivity right now. cant see which tests are failing and passing

dankolesnikov avatar Nov 10 '23 00:11 dankolesnikov

You can pass down your own diff config - https://vitest.dev/config/#diff

sheremet-va avatar Nov 10 '23 06:11 sheremet-va

We decided to allow objects in the diff property (it has expand). The documentation should also contain more information about available diff fields.

When it's an object, you can use --diff.expand=false flag or set diff.expand to false in the config:

export default defineConfig({
  test: {
    diff: {
      expand: false,
    },
  },
})

sheremet-va avatar Oct 10 '24 09:10 sheremet-va