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

Diffs over 2048 characters are truncated even when there is no performance problem #4767

Closed
joshgoebel opened this issue Oct 7, 2021 · 5 comments · Fixed by #4799
Closed
Labels
area: reporters involving a specific reporter

Comments

@joshgoebel
Copy link

joshgoebel commented Oct 7, 2021

Reference: #4638

Can this be a feature flag please so it can be disabled? I was having NO speed issues before but now my test output is entirely broken (it doesn't show the actual diff at all) because it's a bit over 2000 characters. ☹️

This arbitrary 2048 limit does not seem a good heuristic.

Originally posted by @joshgoebel in #4638 (comment)

@KsenyLa
Copy link

KsenyLa commented Oct 7, 2021

I have similar question - can it be disabled? Feature flag would be very helpful

@jnordberg
Copy link

Also running into this, looks like its hardcoded to 2048 chars...

@joshgoebel
Copy link
Author

Correct. At the very least that should be configurable.

@jnordberg
Copy link

jnordberg commented Nov 18, 2021

I think something like this would help in many cases (it certainly would in mine) and will be reasonably fast even for huge inputs.

// truncate beginning of actual and expected strings until first difference if they exceed maxLen
const maxLen = 2048 // TODO: make this configurable :)
const len = Math.max(actual.length, expected.length)
let p = 0
while (len - p > maxLen && actual[p] === expected[p]) {
    p++
}
actual = actual.slice(p, maxLen + p)
expected = expected.slice(p, maxLen + p)

@norla
Copy link
Contributor

norla commented Dec 15, 2021

I have run into this several times so I took the liberty to create a pull request (see above).
@jnordberg I tried including your approach, but skipping to the first diffing character caused some issues with the ouput (not showing enough context, extra diffs at the end etc) so I decided not to use it.

norla added a commit to norla/mocha that referenced this issue Feb 15, 2022
@juergba juergba added the area: reporters involving a specific reporter label Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: reporters involving a specific reporter
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants