Skip to content
This repository has been archived by the owner on Mar 5, 2021. It is now read-only.

Fatal error causes Mocha to exit #16

Open
itsjamie opened this issue Jan 23, 2013 · 9 comments
Open

Fatal error causes Mocha to exit #16

itsjamie opened this issue Jan 23, 2013 · 9 comments
Assignees

Comments

@itsjamie
Copy link

See mochajs/mocha#735

@itsjamie
Copy link
Author

Hello! I believe the issue is in the grunt task itself upon further inspection..

Example

@ghost ghost assigned yaymukund Jan 26, 2013
@yaymukund
Copy link
Owner

Hmm, I can't replicate this, and I'm inclined to think it's a bug with the Mocha API interface.

But I'll take a closer look when I get a chance. I'd love to build on the Mocha API interface when I get some time..

@itsjamie
Copy link
Author

Yea.. I didn't run into this error until I started adding in Webdriver tests via GhostDriver on phantomJS, so maybe there needs to be something additional added, I'll also be looking and see if I can get a solution. As it would be great to not have to use a hacked together solution with alerts and AJAX bridges etc to get front-end testing now that we have a proper selenium driver for PhantomJS.

Thanks for any effort you put in 👍

Hopefully the magic 🎱 will help me in my quest :)

@yaymukund
Copy link
Owner

Thanks for the issue! Are you already aware of the wildly popular grunt-mocha? It's designed for tests using PhantomJS, and there seems to be a lot of code dedicated to printing the results correctly.

I mainly didn't like its dependency on PhantomJS, but you're already using PhantomJS so maybe that won't be an issue for you.. :)

@itsjamie
Copy link
Author

The only reason I haven't hopped over to grunt-mocha is that the project was to support testing on PhantomJS before it was supported. Now, PhantomJS provides a native WebDriver called GhostDriver. So the way that grunt-mocha communicates is neat, but unneeded now. I haven't looked deeply at the source for it but I know older similar types of libraries used iframe + alerts to provide communication, I'd rather be able to use the JSONWireProtocol. I may just use grunt exec or shell and run mocha directly to get the results.. Hm.

@gregrperkins
Copy link

This is a pretty gnarly issue and has been bugging me for a while... Mocha needs uncaughtExceptions to be ignored when running under node, and grunt really doesn't like that (it exits grunt.fail.fatal hard on any of them: https://github.com/gruntjs/grunt/blob/master/lib/grunt.js#L58-60). Ben didn't want to modify that handler (gruntjs/grunt#592), so... https://github.com/gregrperkins/grunt-mocha-hack was my attempt, but it's really rather disgusting. Hopefully the domain solution will be less disgusting in the near future, once uncaughtExceptions don't propagate up (per nodejs/node-v0.x-archive#4375). I didn't want to use grunt-mocha since I expect node.js file interfaces and such in a lot of tests and code under test, and my impression is that those aren't replicated in phantom.

@gregrperkins
Copy link

#29 if you think this is worth it

@Bartvds
Copy link

Bartvds commented May 16, 2013

So it looks like 3 out of 3 serverside grunt + mocha modules on npm have this issue. Maybe you guy's should team up? :)

@searls
Copy link

searls commented Sep 9, 2013

👍 this appears to be an issue with how Mocha#run works. AFAIK it's exiting as soon as the first error is encountered.

Here's my own custom grunt task that also demonstrates this:

Mocha = require('mocha')

module.exports = (grunt) ->
  _ = grunt.util._

  grunt.registerMultiTask "spec", "run specs (under mocha)", ->
    done = @async()
    mocha = new Mocha(@options())
    @filesSrc.forEach(mocha.addFile.bind(mocha))


    grunt.file.expand("#{process.cwd()}/spec/helpers/**/*").forEach (f) -> require(f)

    mocha.run (errorCount) -> done(errorCount == 0)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants