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

Hostile Custom Runner API - Silent crash #2777

Closed
fgarcia opened this issue Apr 23, 2017 · 4 comments
Closed

Hostile Custom Runner API - Silent crash #2777

fgarcia opened this issue Apr 23, 2017 · 4 comments
Labels
type: bug a defect, confirmed by a maintainer

Comments

@fgarcia
Copy link

fgarcia commented Apr 23, 2017

I've just noticed that my custom runner started crashing silently. The problem is that Runner errors cause Mocha to crash with an OK exit status and no error notice.

For example:

var mocha = require('mocha');

function FooReporter(runner) {
  mocha.reporters.Base.call(this, runner);
  
  //return visual(runner)

  let count = 0
  runner.on('suite', function(test){
  })

  runner.on('pass', function(test){
    count++
    if(count > 3) throw Error('An error!')
    process.stdout.write('.')
  });

  runner.on('fail', function(test, err){
    process.stdout.write('x')
  });

  runner.on('end', function(){
    console.log()
    console.log('end!')
  });
}

module.exports = FooReporter;

Using the above runner will silently crash Mocha after 3 test passes. The thrown Error will not be shown and shell exit status of mocha will be 0

@drazisil drazisil added type: bug a defect, confirmed by a maintainer unconfirmed labels Apr 24, 2017
@ScottFreeCode
Copy link
Contributor

This could be related to #2890 (comment)

@ORESoftware
Copy link

You mean custom reporter, not custom runner right?

@fgarcia
Copy link
Author

fgarcia commented Jul 9, 2017 via email

@fgarcia
Copy link
Author

fgarcia commented Jul 12, 2017

Closing this issue because it seems that since my report, now Mocha reporters crash with "reporter blew up with error" message and there is even a stacktrace

@fgarcia fgarcia closed this as completed Jul 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

No branches or pull requests

4 participants