File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed
Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ const bodyParser = require('body-parser');
99const cookieParser = require ( 'cookie-parser' ) ;
1010const nock = require ( 'nock' ) ;
1111const request = require ( '../index.js' ) ;
12+ const throwError = require ( './throwError' ) ;
1213
1314process . env . NODE_TLS_REJECT_UNAUTHORIZED = '0' ;
1415
@@ -748,9 +749,7 @@ describe('request(app)', function () {
748749
749750 it ( 'reports errors' , function ( done ) {
750751 get
751- . expect ( function ( res ) {
752- throw new Error ( 'failed' ) ;
753- } )
752+ . expect ( throwError ( 'failed' ) )
754753 . end ( function ( err ) {
755754 err . message . should . equal ( 'failed' ) ;
756755 shouldIncludeStackWithThisFile ( err ) ;
@@ -774,9 +773,7 @@ describe('request(app)', function () {
774773
775774 it ( 'ensures truthy errors returned from asserts are throw to end' , function ( done ) {
776775 get
777- . expect ( function ( res ) {
778- return new Error ( 'some descriptive error' ) ;
779- } )
776+ . expect ( throwError ( 'some descriptive error' ) )
780777 . end ( function ( err ) {
781778 err . message . should . equal ( 'some descriptive error' ) ;
782779 shouldIncludeStackWithThisFile ( err ) ;
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ /**
4+ * This method needs to reside in its own module in order to properly test stack trace handling.
5+ */
6+ module . exports = function throwError ( message ) {
7+ return function ( ) {
8+ throw new Error ( message ) ;
9+ } ;
10+ } ;
You can’t perform that action at this time.
0 commit comments