-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
No diff in html report #1348
Comments
Try changing your chai truncation threshold to disable truncation, like so:
|
@callmevlad It helped me, but not solves issue at all. |
I have the same problem with the tdd ui. |
Wait. Uncaught errors? That's not the same problem as the one mentioned above, right? |
I too have this issue. It'd be great to get the diffs in the browser version. |
The actual problem here is that the HTML reporter literally doesn't show diffs. The code of how the HTML reporter constructs the failure HTML is between L158-188. It does not check if the error has a diff, and so does not render one. It needs something along the lines of the Base Reporters diff logic (which it does upon summary); around L193-215. Has the HTML reporter ever shown diffs for anyone? |
No, the HTML reporter has never shown diffs. I requested this in #1071, which was recently closed in favour of letting the assertion library do it. So this is actually a duplicate. |
@lydell I'm not sure it'd make much sense for an assertion library to do diffs, because of the variety of output formats that'd be needed. Mocha's reporters can send coloured escape codes for terminal, and HTML tags for HTML reporting - because a mocha reporter is context aware, assertion libraries are not. |
+1 I reported this issue in karma-mocha In this bit of code: The The base runner currently is leveraging it I can work on adding this to the html reporter. |
Yes do! |
Ok, I'll work on it! |
+1 |
+1 Any workaround for this currently? |
I'm using modern-diff to generate little diffs that look like... dif({a: 1, b: 2, c: 3}, {b: 22, c: 3, d: 4})
/*
[
['-', ['a'], 1],
['r', ['b'], 2, 22],
['+', ['d'], 4]
]
*/ and my own little chai.expect helper for the error message. |
In the meantime - if you're using chai - you can set |
I'm running into the same problem. |
Diffing has been an issue for a long time. I would like to leverage a third-party lib (or libs) for this. Requirements:
nice to have:
I'm welcome to suggestions for modules that would fulfill the requirements. If nothing exists, maybe we should write one with Mocha in mind? |
@boneskull Multiple things on npm that might catch your eye. They simply create a machine-readable diff, which walking the two objects to format it wouldn't be that hard to do (although not quite trivial). |
unexpected. js has really nice string and object diffs. Don't know how that's implemented, though. Hopefully in a modular way :) |
@boneskull there are currently no tests on the html reporter. I'm thinking of adding some. Would you be ok with jsdom being added to the dev dependencies for use in testing the generated html? |
👍 |
I came from this issue and it's title describes precisely my problem. Using karma/mocha/chai with deepEqual I get the following output in console:
|
👍 |
actually I'm going to kill this because it's not really actionable aside from the continuing lack of tests of the html reporter. if we want better / different diffs, someone should propose something concrete. |
Here is "something concrete": looks this: In the browser too. Not only in the console. How can one be more concrete? It's a missing feature, it's very obvious what "concrete thing" is requested here. Also I'd say this is the biggest feature Mocha is missing. Not being able to render diffs is a major drawback! And don't know what you mean by "continuing lack of tests of the html reporter". All reports of this issue likely will test the HTML reporter. And if you don't want to maintain it, remove it, but do not pretend to support it. |
This is what I mean:
"Concrete" refers to the diff implementation itself, which likely won't transfer cleanly from the console to the browser. I was hoping for "let's use module X, because it fulfills all of the requirements," or a proposal to create a module which does. @rugk It's clear you're frustrated by this missing feature. But please take care not to make condescending comments or place demands on volunteer contributors to this project. |
Great to hear, but then you may need to add these stuff still missing in that reporter.
We don't even have a list of requirements, but aside from this lib, which already has been mentioned, but does not provide HTML support as it seems, there are a lot libraries:
I'd say diff2html looks promising and up-to-date (it's also easily to embed in a browser), but generally one may also have a look at what GitLab/GitHub/etc. use. They all have this implemented. @boneskull It's clear you see some missing other stuff about the reporter and more important6 things to do. However, please acknowledge this issue here is valid and unsolved, and as such re-open it. I see no reason why it should be closed. You may mark it as "blocked" indicating no one should/can work on this, but acknowledge the general idea that this is missing. |
A little bit of a sidebar as it's not the default html reporter, but we just pushed out a beta of our new mocha reporter and we integrated diff2html into it. We tore diff2html apart a bit, so that area still needs some clean up, but I'd be interested in what people think. The 'Diff comparison' suite has a couple samples in it. |
Any news on this? This is closed, but it is still a very valuable feature. |
@boneskull, why close this issue? The requirements are fairly clear, fairly popular (see multiple related tickets linked here), and certainly not met. 7 years later people are still coming here to request it. For those who find this in the distant future, |
true story |
I've created a simple test example using latest
[email protected]
and[email protected]
When I am running the test in console, it works good and I see a diff in output
But in browser I can't see a diff.
If need, there is a code of
runner.html
The text was updated successfully, but these errors were encountered: