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

Errors in async code outside of a testsuite results in TypeError #55

Open
marconius opened this issue Nov 22, 2018 · 0 comments
Open

Errors in async code outside of a testsuite results in TypeError #55

marconius opened this issue Nov 22, 2018 · 0 comments

Comments

@marconius
Copy link

Expected behavior

The actual Error is exposed in the results. e.g:

1) Uncaught error outside test suite

  0 passing (0ms)
  1 failing

  1) Uncaught error outside test suite:
     Uncaught Error: TEST TEST
      at Timeout.setTimeout (test/mocha-init.js:38:9)

Actual behavior

A TypeError is exposed:

  1) Uncaught error outside test suite                                                                                                                                                                                                                                           
/path/to/project/node_modules/mocha-junit-reporter/index.js:106                                                                                                                                                                                                      
    return testsuites[testsuites.length - 1].testsuite;                                                                                                                                                                                                                          
                                             ^                                                                                                                                                                                                                                   
                                                                                                                                                                                                                                                                                 
TypeError: Cannot read property 'testsuite' of undefined                                                                                                                                                                                                                         
    at lastSuite (/path/to/project/node_modules/mocha-junit-reporter/index.js:106:46)                                                                                                                                                                                
    at MochaJUnitReporter.<anonymous> (/path/to/project/node_modules/mocha-junit-reporter/index.js:131:5)                                                                                                                                                            
    at emitTwo (events.js:131:20)                                                                                                                                                                                                                                                
    at Runner.emit (events.js:214:7)                                                                                                                                                                                                                                             
    at Runner.fail (/path/to/project/node_modules/mocha/lib/runner.js:251:8)                                                                                                                                                                                         
    at Runner.uncaught (/path/to/project/node_modules/mocha/lib/runner.js:739:12)                                                                                                                                                                                    
    at process.uncaught (/path/to/project/node_modules/mocha/lib/runner.js:839:10)                                                                                                                                                                                   
    at emitOne (events.js:116:13)                                                                                                                                                                                                                                                
    at process.emit (events.js:211:7)                                                                                                                                                                                                                                            
    at process._fatalException (bootstrap_node.js:378:26)

Information about the Issue

Occurs when an error goes unhandled in async code outside of a testsuite.

Steps to reproduce the behavior

  1. Throw an error asynchronously in mocha-init.js
// somewhere in mocha-init.js

setTimeout(() => {
  throw new Error("TEST TEST");
}, 1000);
  1. run tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant