@@ -10,7 +10,7 @@ describe('error handling', () => {
1010 } ) ;
1111
1212 test ( 'should return an unknown error when something unexpected is returned' , async ( ) => {
13- const scope = interceptor . reply ( 500 , '🌶️' ) ;
13+ const scope = interceptor . reply ( 500 , '🌶️' , { 'apigw-requestid' : 'req_4' } ) ;
1414
1515 const client = new PlainClient ( { apiKey : '123' } ) ;
1616
@@ -19,13 +19,18 @@ describe('error handling', () => {
1919 expect ( result . error ) . toEqual ( {
2020 type : 'internal_server_error' ,
2121 message : 'Internal server error.' ,
22+ requestId : 'req_4' ,
2223 } ) ;
2324
2425 scope . done ( ) ;
2526 } ) ;
2627
2728 test ( 'should return a forbidden error when API 401s' , async ( ) => {
28- const scope = interceptor . matchHeader ( 'Authorization' , 'Bearer 123' ) . reply ( 401 , 'unauthorized' ) ;
29+ const scope = interceptor
30+ . matchHeader ( 'Authorization' , 'Bearer 123' )
31+ . reply ( 401 , 'unauthorized' , {
32+ 'apigw-requestid' : 'req_5' ,
33+ } ) ;
2934
3035 const client = new PlainClient ( { apiKey : '123' } ) ;
3136
@@ -34,13 +39,16 @@ describe('error handling', () => {
3439 expect ( result . error ) . toEqual ( {
3540 type : 'forbidden' ,
3641 message : expect . stringContaining ( 'Authentication failed' ) ,
42+ requestId : 'req_5' ,
3743 } ) ;
3844
3945 scope . done ( ) ;
4046 } ) ;
4147
4248 test ( 'should return a forbidden error when API 403s' , async ( ) => {
43- const scope = interceptor . matchHeader ( 'Authorization' , 'Bearer 123' ) . reply ( 403 , 'forbidden' ) ;
49+ const scope = interceptor . matchHeader ( 'Authorization' , 'Bearer 123' ) . reply ( 403 , 'forbidden' , {
50+ 'apigw-requestid' : 'req_6' ,
51+ } ) ;
4452
4553 const client = new PlainClient ( { apiKey : '123' } ) ;
4654
@@ -49,26 +57,33 @@ describe('error handling', () => {
4957 expect ( result . error ) . toEqual ( {
5058 type : 'forbidden' ,
5159 message : expect . stringContaining ( 'Authentication failed' ) ,
60+ requestId : 'req_6' ,
5261 } ) ;
5362
5463 scope . done ( ) ;
5564 } ) ;
5665
5766 test ( 'should return a forbidden error when API responds with mutation error' , async ( ) => {
58- const scope = interceptor . matchHeader ( 'Authorization' , 'Bearer 123' ) . reply ( 200 , {
59- data : {
60- updateCustomerGroup : {
61- customerGroup : null ,
62- error : {
63- __typename : 'MutationError' ,
64- message : 'Insufficient permissions, missing "customerGroup:edit".' ,
65- type : 'FORBIDDEN' ,
66- code : 'forbidden' ,
67- fields : [ ] ,
67+ const scope = interceptor . matchHeader ( 'Authorization' , 'Bearer 123' ) . reply (
68+ 200 ,
69+ {
70+ data : {
71+ updateCustomerGroup : {
72+ customerGroup : null ,
73+ error : {
74+ __typename : 'MutationError' ,
75+ message : 'Insufficient permissions, missing "customerGroup:edit".' ,
76+ type : 'FORBIDDEN' ,
77+ code : 'forbidden' ,
78+ fields : [ ] ,
79+ } ,
6880 } ,
6981 } ,
7082 } ,
71- } ) ;
83+ {
84+ 'apigw-requestid' : 'req_7' ,
85+ }
86+ ) ;
7287
7388 const client = new PlainClient ( { apiKey : '123' } ) ;
7489
@@ -77,6 +92,7 @@ describe('error handling', () => {
7792 expect ( result . error ) . toEqual ( {
7893 type : 'forbidden' ,
7994 message : 'Insufficient permissions, missing "customerGroup:edit".' ,
95+ requestId : 'req_7' ,
8096 } ) ;
8197
8298 scope . done ( ) ;
0 commit comments