File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,11 @@ const outputErrorInfo = async (testPage) => {
1010 ` ;
1111} ;
1212
13+ const outputRedirectInfo = ( testPage ) => {
14+ const headers = testPage . response . headers ( ) ;
15+ return `Status = ${ testPage . status } . Redirected to ${ headers [ 'location' ] } ` ;
16+ }
17+
1318module . exports = async ( testPage ) => {
1419 if ( testPage . check . status === 204 ) {
1520 //eslint-disable-next-line no-console
@@ -22,10 +27,16 @@ module.exports = async (testPage) => {
2227 result : testPage . redirect && testPage . check . status === testPage . redirect . to
2328 } ;
2429 } else {
30+ const redirectStatusCodes = [ 301 , 302 , 307 , 308 ]
2531 const isUnexpectedHttpError = testPage . check . status !== 500 && testPage . status === 500 ;
32+ const isUnexpectedRedirect = ! redirectStatusCodes . includes ( testPage . check . status ) && redirectStatusCodes . includes ( testPage . status )
2633 return {
2734 expected : `Status = ${ testPage . check . status } ` ,
28- actual : isUnexpectedHttpError ? await outputErrorInfo ( testPage ) : `Status = ${ testPage . status } ` ,
35+ actual : (
36+ isUnexpectedHttpError ? await outputErrorInfo ( testPage )
37+ : isUnexpectedRedirect ? outputRedirectInfo ( testPage )
38+ : `Status = ${ testPage . status } `
39+ ) ,
2940 result : testPage . status === testPage . check . status || testPage . status === 304 && testPage . check . status === 200
3041 } ;
3142 }
You can’t perform that action at this time.
0 commit comments