Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3k
Limit the size of 'actual'/'expected' strings before generating a diff#4638
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
@@ -164,6 +164,34 @@ describe('Base reporter', function() { | |||
' \n actual expected\n \n a foobar inline diff\n ' | |||
); | |||
}); | |||
it("should truncate overly long 'actual' ", function() { | |||
var actual = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Hello, I'm trying to contribute to Mocha and before I do I'm trying to get idea of mocha's coding style. I want to know why you used 'var' instea of 'const' or 'let'. Thank you in advance.
joshgoebel commentedOct 7, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Can this be a feature flag please so it can be disabled? I was having NO speed issues before but not my test output is entirely broken (it doesn't show the actual diff at all) because it's a bit over 2000 characters. |
Uh oh!
There was an error while loading.Please reload this page.
Description
Mocha prints its own diff on assertion errors by stringifying
err.actual
anderr.expected
, then passing both strings tojsdiff for generating a diff-patch. For big strings this synchronous process can take several minutes.jsdiff has some known performance issues, so in mid-term we evtl. should evaluate ajsdiff alternative.
On the other hand it's not a good idea to calculate a diff for two huge strings, even with a faster algorithm. We should limit the size of the input strings, as eg. done by Node's
assert
as well.Description of the Change
err.actual
anderr.expected
... Lines skipped
Applicable issues
closes#3675