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

toEqual output is truncated #3762

Closed
6 tasks done
PupoSDC opened this issue Jul 12, 2023 · 9 comments
Closed
6 tasks done

toEqual output is truncated #3762

PupoSDC opened this issue Jul 12, 2023 · 9 comments

Comments

@PupoSDC
Copy link

PupoSDC commented Jul 12, 2023

Describe the bug

This is a follow up to #2448 Since I simply don't understand the solution being proposed.

When running a test to check the equality of two objects, the output is truncated if there are more than 2 properties.

I.e. the output looks like this:

AssertionError: expected { hello: 'world', …(3) } to deeply equal { hello: 'world', …(2) }

Which means it's not possible to establish what was wrong.

I wondered if setting this might help but it doesn't seem to make a difference here.

Here is the output i see on my console:

image

Here is the output from Jest, which is more or less what I was expecting to see:

image

How can i make it so that the full diff between the provided and expected value is shown on the console?

Reproduction

In this repo there's a test called it demonstrates toEqual output is truncated in ApiCaller.test.ts that shows the problem.

System Info

System:
    OS: macOS 13.4
    CPU: (8) arm64 Apple M1 Pro
    Memory: 3.56 GB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.16.1 - ~/Library/Caches/fnm_multishells/54988_1688995060872/bin/node
    Yarn: 1.22.19 - ~/Library/Caches/fnm_multishells/54988_1688995060872/bin/yarn
    npm: 9.5.1 - ~/Library/Caches/fnm_multishells/54988_1688995060872/bin/npm
  Browsers:
    Chrome: 114.0.5735.198
    Safari: 16.5

Used Package Manager

yarn

Validations

@sheremet-va
Copy link
Member

Linked reproduction prints the output

Screenshot 2023-07-12 at 10 17 41

@github-actions
Copy link

Hello @PupoSDC. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.

@PupoSDC
Copy link
Author

PupoSDC commented Jul 12, 2023

Thank you for your reply. Our setup was missing the following config on vite.config.js:

export default defineConfig(() => {
  return test {
      outputTruncateLength: 10000,
      outputDiffLines: 100000,
  }
}

It appears that by default no diff is generated.

Thank you!

@PupoSDC PupoSDC closed this as completed Jul 12, 2023
@sheremet-va
Copy link
Member

Thank you for your reply. Our setup was missing the following config on vite.config.js:

export default defineConfig(() => {
  return test {
      outputTruncateLength: 10000,
      outputDiffLines: 100000,
  }
}

It appears that by default no diff is generated.

Thank you!

Both of these options are not supported by Vitest for some time now.

@PupoSDC
Copy link
Author

PupoSDC commented Jul 12, 2023

So what Options should I set? These 2 seem to work on vitest: 0.33.0.

Which is supposed to be the correct set of options for this version?
And where can i find the docs for them?

@sheremet-va
Copy link
Member

So what Options should I set? These 2 seem to work on vitest: 0.33.0.

Which is supposed to be the correct set of options for this version? And where can i find the docs for them?

There are no options for diff. It should just work, and it works without any options in linked reproduction.

@Mouvedia
Copy link

Capture d’écran 2023-07-13 à 12 14 49

@PupoSDC
Copy link
Author

PupoSDC commented Jul 13, 2023

@Mouvedia Check if you are running the latest vite (0.33 at this date) that was the issue for me.
On this version the settings flag outputTruncateLength, outputDiffLines are indeed not needed.

@Mouvedia
Copy link

I am using version 0.33.0.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants