@@ -28,7 +28,7 @@ test('properties', withServer, async (t, server, got) => {
2828 t . true ( Object . prototype . propertyIsEnumerable . call ( error , 'options' ) ) ;
2929 t . false ( Object . prototype . propertyIsEnumerable . call ( error , 'response' ) ) ;
3030 t . is ( error . code , 'ERR_NON_2XX_3XX_RESPONSE' ) ;
31- t . is ( error . message , 'Response code 404 (Not Found)' ) ;
31+ t . regex ( error . message , / ^ R e q u e s t f a i l e d w i t h s t a t u s c o d e 4 0 4 \ (N o t F o u n d \) : G E T h t t p : \/ \/ l o c a l h o s t : \d + \/ $ / ) ;
3232 t . deepEqual ( error . options . url , url ) ;
3333 t . is ( error . response . headers . connection , 'keep-alive' ) ;
3434 // Assert is used for type checking
@@ -78,7 +78,7 @@ test('default status message', withServer, async (t, server, got) => {
7878 const error = await t . throwsAsync < HTTPError > ( got ( '' ) ,
7979 {
8080 instanceOf : HTTPError ,
81- message : 'Response code 400 (Bad Request)' ,
81+ message : / ^ R e q u e s t f a i l e d w i t h s t a t u s c o d e 4 0 0 \ (B a d R e q u e s t \) : G E T h t t p : \/ \/ l o c a l h o s t : \d + \/ $ / ,
8282 } ) ;
8383 t . is ( error ?. response . statusCode , 400 ) ;
8484 t . is ( error ?. response . statusMessage , 'Bad Request' ) ;
@@ -94,7 +94,7 @@ test('custom status message', withServer, async (t, server, got) => {
9494 const error = await t . throwsAsync < HTTPError > ( got ( '' ) ,
9595 {
9696 instanceOf : HTTPError ,
97- message : 'Response code 400 (Something Exploded)' ,
97+ message : / ^ R e q u e s t f a i l e d w i t h s t a t u s c o d e 4 0 0 \ (S o m e t h i n g E x p l o d e d \) : G E T h t t p : \/ \/ l o c a l h o s t : \d + \/ $ / ,
9898 } ) ;
9999 t . is ( error ?. response . statusCode , 400 ) ;
100100 t . is ( error ?. response . statusMessage , 'Something Exploded' ) ;
@@ -109,7 +109,7 @@ test('custom body', withServer, async (t, server, got) => {
109109 const error = await t . throwsAsync < HTTPError > ( got ( '' ) ,
110110 {
111111 instanceOf : HTTPError ,
112- message : 'Response code 404 (Not Found)' ,
112+ message : / ^ R e q u e s t f a i l e d w i t h s t a t u s c o d e 4 0 4 \ (N o t F o u n d \) : G E T h t t p : \/ \/ l o c a l h o s t : \d + \/ $ / ,
113113 } ) ;
114114 t . is ( error ?. response . statusCode , 404 ) ;
115115 // Typecheck for default `any` type
@@ -128,7 +128,7 @@ test('custom json body', withServer, async (t, server, got) => {
128128 const error = await t . throwsAsync < HTTPError < { message : string } > > ( got ( '' , { responseType : 'json' } ) ,
129129 {
130130 instanceOf : HTTPError ,
131- message : 'Response code 404 (Not Found)' ,
131+ message : / ^ R e q u e s t f a i l e d w i t h s t a t u s c o d e 4 0 4 \ (N o t F o u n d \) : G E T h t t p : \/ \/ l o c a l h o s t : \d + \/ $ / ,
132132 } ) ;
133133 t . is ( error ?. response . statusCode , 404 ) ;
134134 // Assert is used for body typecheck
@@ -150,7 +150,7 @@ test('contains Got options', withServer, async (t, server, got) => {
150150 const error = await t . throwsAsync < HTTPError > ( got ( options ) ,
151151 {
152152 instanceOf : HTTPError ,
153- message : 'Response code 404 (Not Found)' ,
153+ message : / ^ R e q u e s t f a i l e d w i t h s t a t u s c o d e 4 0 4 \ (N o t F o u n d \) : G E T h t t p : \/ \/ l o c a l h o s t : \d + \/ $ / ,
154154 } ) ;
155155 t . is ( error ?. response . statusCode , 404 ) ;
156156 t . is ( error ?. options . context . foo , options . context . foo ) ;
@@ -165,7 +165,7 @@ test('empty status message is overriden by the default one', withServer, async (
165165 const error = await t . throwsAsync < HTTPError > ( got ( '' ) ,
166166 {
167167 instanceOf : HTTPError ,
168- message : 'Response code 400 (Bad Request)' ,
168+ message : / ^ R e q u e s t f a i l e d w i t h s t a t u s c o d e 4 0 0 \ (B a d R e q u e s t \) : G E T h t t p : \/ \/ l o c a l h o s t : \d + \/ $ / ,
169169 } ) ;
170170 t . is ( error ?. response . statusCode , 400 ) ;
171171 t . is ( error ?. response . statusMessage , http . STATUS_CODES [ 400 ] ) ;
0 commit comments