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

Fix #2083: HTML reporter regression causing duplicate error output #2112

Merged
merged 1 commit into from
May 25, 2016
Merged

Fix #2083: HTML reporter regression causing duplicate error output #2112

merged 1 commit into from
May 25, 2016

Conversation

danielstjules
Copy link
Contributor

Fixed #2083

This is a minor refactor of the HTML reporter to listen to pass/fail/pending events rather than test end, just like the spec/dot reporters.


As seen below, the sync error is displayed only a single time:


screen shot 2016-02-16 at 12 16 50 am


And the async errors are each correctly displayed. This is the behavior #1981 was intended to fix. Prior to that PR, none of the errors below were displayed in the HTML reporter.


screen shot 2016-02-16 at 12 16 57 am

@danielstjules
Copy link
Contributor Author

cc @boneskull

@danielstjules
Copy link
Contributor Author

This is compatible with #2081 since the pending event now fires after checking isPending()

@boneskull
Copy link
Contributor

@danielstjules cool. do you have any recommendations for how to test this?

@boneskull
Copy link
Contributor

#2079 is still a thing.

@boneskull
Copy link
Contributor

I really don't want to release anything without #2079 being addressed in some fashion

@danielstjules
Copy link
Contributor Author

Aside from manual testing? If you open test/browser/index.html in master, you'll see that normal errors are duplicated, but async errors after a test completed are correctly shown:

screen shot 2016-02-17 at 9 26 24 am

screen shot 2016-02-17 at 9 26 36 am

Comparing that against the build of this PR/branch, async errors post-test completion are still shown, and normal errors are only rendered once.

@danielstjules
Copy link
Contributor Author

In regards to the async errors, this is the same expected behavior seen from the node reporters:

$ cat example.js
it('test', function(done) {
  setTimeout(done, 10);
  setTimeout(done, 20);
});

it('test2', function(done) {
  setTimeout(done, 30);
});

$ ./bin/mocha example.js


  ․․․

  2 passing (51ms)
  1 failing

  1)  test:
     Error: done() called multiple times
      at Test.Runnable (lib/runnable.js:54:17)
      at new Test (lib/test.js:22:12)
      at context.it.context.specify (lib/interfaces/bdd.js:85:18)
      at Object.<anonymous> (example.js:1:63)
      at Array.forEach (native)
      at Object.<anonymous> (bin/_mocha:403:18)
      at node.js:868:3

@danielstjules
Copy link
Contributor Author

I really don't want to release anything without #2079 being addressed in some fashion

I can work on that tonight. But I don't think I'll have an exhaustive enough automated browser test suite ready to reveal issues beyond manually running those HTML files in IE8/Safari/Chrome.

@boneskull
Copy link
Contributor

at minimum then I'd want someone to test IE8, phantomjs 1.x and phantomjs 2.x manually. specifically, see if mochify breaks.

This was referenced Mar 25, 2016
@jnbt
Copy link

jnbt commented Apr 4, 2016

Any updates on this? I think the HTML reports are still broken...

@justinfagnani
Copy link

Also curious about this PR, the bug is messing with reporting downstream of mocha. Are all PRs on hold until #2079 is resolved?

@dasilvacontin
Copy link
Contributor

@justindujardin pretty much, sorry for the hassle.

@justinfagnani
Copy link

Honestly, this makes me question our dependence on Mocha. This fix is 2 months old.

@ScottFreeCode
Copy link
Contributor

ScottFreeCode commented May 3, 2016

I've been experimenting with a set of tests to check for problems like this. It isn't pretty, I don't know if it will work in any kind of automatic testing such as discussed in #2079, and the CLI won't work unless I can get the same HTML report as the browser uses; but at least the set of test cases should be a good starting point (although you may have to go through and tweak which situations are intended to be reported as how many passes and failures, I'm not 100% sure I got it right). It's also not really unit-testing the matter -- if there's the wrong number of results there's no indication as to whether it's a flaw in the test runner or the reporter, if there's the right number of results that doesn't mean the responsibilities involved in getting them are correctly divided between the test runner and the reporter -- but it's better than nothing, I figure (I guess if we wanted to unit test Mocha's internals we'd have to use the non-bundled scripts... and to make it run in the browser would probably end up basically creating a second bundle containing the internal unit tests?...).

I've put what I've got so far up in a gist here: https://gist.github.com/ScottFreeCode/f8b0864781414f96594f67b77ddee469

@maciejjankowski
Copy link

I wonder why is this stalled...
shouldn't you add PR Please label?

@pluma
Copy link

pluma commented May 19, 2016

I can see why you would want to fix #2079 first but this change is trivial compared to the rabbit hole that is automated browser testing. I believe greenlighting this fix despite the freeze would help a lot of people. As it is, #2083 is making browser reports significantly less useful, so the question of browser support doesn't really come into it.

@boneskull
Copy link
Contributor

I'm going to rebase this onto master and see what happens.

}

function updateStats() {
// TODO: add to stats
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danielstjules does this TODO mean this PR isn't ready?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danielstjules true again

@boneskull
Copy link
Contributor

In general, I think this looks good. Just want some feedback from @danielstjules to ensure it's ready to merge.

@boneskull boneskull added area: browser browser-specific High priority status: waiting for author waiting on response from OP - more information needed labels May 23, 2016

// <=IE7 stringifies to [Object Error]. Since it can be overloaded, we
// check for the result of the stringifying.
if (message === '[object Error]') {
Copy link
Contributor

@dasilvacontin dasilvacontin May 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the comment you mention [Object Error], but in the code it uses a different casing. (O->o)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dasilvacontin the code is correct, the comment is wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clearing it up @pluma!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look further down, I didn't write the comment, just moved around the code :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danielstjules true :)

@dasilvacontin
Copy link
Contributor

LGTM. Sync error is only reported once now. Waiting for the reply about the TODO, will release in a day or two if no response is given.

@dasilvacontin
Copy link
Contributor

btw: sorry for the wait internet people.

@danielstjules
Copy link
Contributor Author

The diff is unfortunately long for what was a minor refactor. A lot of the code was moved around rather than modified.

@dasilvacontin dasilvacontin merged commit 6d24063 into mochajs:master May 25, 2016
@dasilvacontin
Copy link
Contributor

Thanks for the fix @danielstjules :). I released it already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: browser browser-specific
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression: Failures rendering twice
8 participants