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

Option to customize the maximum truncated output #962

Closed
4 tasks done
shuding opened this issue Mar 16, 2022 · 5 comments · Fixed by #977
Closed
4 tasks done

Option to customize the maximum truncated output #962

shuding opened this issue Mar 16, 2022 · 5 comments · Fixed by #977
Labels
enhancement New feature or request pr welcome

Comments

@shuding
Copy link

shuding commented Mar 16, 2022

Clear and concise description of the problem

Currently Vitest uses process.stdout.columns || 80 as the limit of diff output. It would be great to have a way to customize that size, especially when you have a really long test snapshot.

- Expected   "something …
+ Received   "something …

Suggested solution

An outputTruncateLength option.

Alternative

No response

Additional context

No response

Validations

@antfu antfu added enhancement New feature or request pr welcome labels Mar 16, 2022
@cuixiaorui
Copy link

cuixiaorui commented Mar 18, 2022

please do you provide a demo for 'long test snapshot'

i need more context

@styfle
Copy link

styfle commented Mar 18, 2022

@cuixiaorui Here's an example where the color of the svg was red but we expected blue. The output in the default macOS Terminal does not show the diff, instead it truncates.

import { it, expect } from 'vitest'

it('truncated', () => {
  const input = '<svgwidth="2000"height="4000"xmlns="http://www.w3.org/2000/svg"><pathd="M1010"/><circlecx="10"cy="10"r="2"fill="red"/></svg>'
  const output = '"<svgwidth=\\"2000\\"height=\\"4000\\"xmlns=\\"http://www.w3.org/2000/svg\\"><pathd=\\"M1010\\"/><circlecx=\\"10\\"cy=\\"10\\"r=\\"2\\"fill=\\"blue\\"/></svg>"'
  expect(input).toMatchInlineSnapshot(output)
})

image

@Aslemammad
Copy link
Member

@styfle Let me check your demo and see if it's possible!

@jcalfee
Copy link

jcalfee commented Mar 15, 2023

Where do I look when output is still truncated even though I specify vitest --outputTruncateLength 9999? (see #2671)

@nandastone
Copy link

nandastone commented Mar 23, 2023

If you're using testing-library and diffing DOM output please note it has its own internal print limit:

DEBUG_PRINT_LIMIT=100000 pnpm test

https://testing-library.com/docs/dom-testing-library/api-debugging/#automatic-logging

@github-actions github-actions bot locked and limited conversation to collaborators Jun 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request pr welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants