File tree Expand file tree Collapse file tree 4 files changed +50
-0
lines changed
Expand file tree Collapse file tree 4 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -209,6 +209,10 @@ echo 'TESTCASE: unhandled rejections should not force subprocess to exit'
209209test test/q-promises/index.js
210210showTestResult $?
211211
212+ echo ' TESTCASE: uncaught exceptions should not force subprocess to exit'
213+ test test/uncaught-exception/index.js
214+ showTestResult $?
215+
212216echo " Passes: $PASSES Failes: $FAILES "
213217
214218if [ $FAILES -gt 0 ]; then
Original file line number Diff line number Diff line change 1+ Make sure that uncaught exceptions do not stop executing the tests
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env node
2+
3+ const assert = require ( 'assert' ) ;
4+ const sinon = require ( 'sinon' ) ;
5+
6+ const MochaParallelTests = require ( '../../dist/main/mocha' ) . default ;
7+ const { setProcessExitListeners } = require ( '../../dist/util' ) ;
8+ const SilentReporter = require ( '../util/silent-reporter' ) ;
9+
10+ setProcessExitListeners ( ) ;
11+
12+ const onRunnerEnd = sinon . fake ( ) ;
13+ const onTestEnd = sinon . fake ( ) ;
14+ const mocha = new MochaParallelTests ;
15+ mocha . reporter ( SilentReporter ) ;
16+ mocha . addFile ( `${ __dirname } /index.spec.js` ) ;
17+
18+ mocha . run ( )
19+ . on ( 'end' , onRunnerEnd )
20+ . on ( 'test end' , onTestEnd ) ;
21+
22+ process . on ( 'exit' , ( ) => {
23+ assert . strictEqual ( onRunnerEnd . callCount , 1 , `runner "end" event occured wrong number of times: ${ onRunnerEnd . callCount } ` ) ;
24+ assert . strictEqual ( onTestEnd . callCount , 4 , `runner "test end" event occured wrong number of times: ${ onTestEnd . callCount } ` ) ;
25+ } ) ;
Original file line number Diff line number Diff line change 1+ describe ( 'suite' , function ( ) {
2+ it ( 'case 1' , function ( ) {
3+ throw new Error ( 'foo' ) ;
4+ } ) ;
5+
6+ // eslint-disable-next-line no-unused-vars
7+ it ( 'case 2' , function ( done ) {
8+ setTimeout ( ( ) => {
9+ throw new Error ( 'foo' ) ;
10+ } , 100 ) ;
11+ } ) ;
12+
13+ it ( 'case 3' , ( ) => { } ) ;
14+
15+ it ( 'case 4' , ( ) => {
16+ return new Promise ( ( ) => {
17+ throw new Error ( 'foo' ) ;
18+ } ) ;
19+ } ) ;
20+ } ) ;
You can’t perform that action at this time.
0 commit comments