@@ -142,6 +142,14 @@ describe('app', function(){
142142
143143 it ( 'should deprecate when redirect called without a url' , function ( done ) {
144144 var app = express ( )
145+ var warnings = [ ]
146+
147+ // Capture deprecation warnings
148+ process . on ( 'warning' , function ( warning ) {
149+ if ( warning . name === 'DeprecationWarning' ) {
150+ warnings . push ( warning . message )
151+ }
152+ } )
145153
146154 app . use ( function ( req , res ) {
147155 res . redirect ( '' )
@@ -151,11 +159,22 @@ describe('app', function(){
151159 . get ( '/' )
152160 . expect ( 302 )
153161 . expect ( 'Location' , '' )
154- . expect ( / R e d i r e c t i n g t o / , done )
162+ . expect ( / R e d i r e c t i n g t o / , function ( ) {
163+ assert ( warnings . some ( msg => msg . includes ( 'res.redirect(url): Use res.redirect(status, url) instead' ) ) )
164+ done ( )
165+ } )
155166 } )
156167
157168 it ( 'should deprecate when redirect address is not a string' , function ( done ) {
158169 var app = express ( )
170+ var warnings = [ ]
171+
172+ // Capture deprecation warnings
173+ process . on ( 'warning' , function ( warning ) {
174+ if ( warning . name === 'DeprecationWarning' ) {
175+ warnings . push ( warning . message )
176+ }
177+ } )
159178
160179 app . use ( function ( req , res ) {
161180 res . redirect ( 302 , 123 )
@@ -165,7 +184,10 @@ describe('app', function(){
165184 . get ( '/' )
166185 . expect ( 302 )
167186 . expect ( 'Location' , '123' )
168- . expect ( / R e d i r e c t i n g t o 1 2 3 / , done )
187+ . expect ( / R e d i r e c t i n g t o 1 2 3 / , function ( ) {
188+ assert ( warnings . some ( msg => msg . includes ( 'res.redirect(url, status): Use res.redirect(status, url) instead' ) ) )
189+ done ( )
190+ } )
169191 } )
170192
171193 it ( 'should raise when redirect status is not a number' , function ( done ) {
0 commit comments