File tree 2 files changed +13
-6
lines changed
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');
9
9
const cookieParser = require ( 'cookie-parser' ) ;
10
10
const nock = require ( 'nock' ) ;
11
11
const request = require ( '../index.js' ) ;
12
+ const throwError = require ( './throwError' ) ;
12
13
13
14
process . env . NODE_TLS_REJECT_UNAUTHORIZED = '0' ;
14
15
@@ -748,9 +749,7 @@ describe('request(app)', function () {
748
749
749
750
it ( 'reports errors' , function ( done ) {
750
751
get
751
- . expect ( function ( res ) {
752
- throw new Error ( 'failed' ) ;
753
- } )
752
+ . expect ( throwError ( 'failed' ) )
754
753
. end ( function ( err ) {
755
754
err . message . should . equal ( 'failed' ) ;
756
755
shouldIncludeStackWithThisFile ( err ) ;
@@ -774,9 +773,7 @@ describe('request(app)', function () {
774
773
775
774
it ( 'ensures truthy errors returned from asserts are throw to end' , function ( done ) {
776
775
get
777
- . expect ( function ( res ) {
778
- return new Error ( 'some descriptive error' ) ;
779
- } )
776
+ . expect ( throwError ( 'some descriptive error' ) )
780
777
. end ( function ( err ) {
781
778
err . message . should . equal ( 'some descriptive error' ) ;
782
779
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