@@ -85,67 +85,113 @@ and some after the error message
85
85
assert . deepStrictEqual ( actual ?. cause ?. message , testError . cause ?. message ) ;
86
86
} ) ;
87
87
88
- void it ( 'deserialize when string is encoded with single quote and has double quotes in it' , ( ) => {
89
- const sampleStderr = `some random stderr
88
+ void describe ( 'V1 deserialization' , ( ) => {
89
+ void it ( 'deserialize when string is encoded with single quote and has double quotes in it' , ( ) => {
90
+ const sampleStderr = `some random stderr
90
91
${ util . inspect ( {
91
92
serializedError :
92
93
'{"name":"SyntaxError","classification":"ERROR","options":{"message":"test error message","resolution":"test resolution"}}' ,
93
94
} ) }
94
95
and some after the error message
95
96
` ;
96
- const actual = AmplifyError . fromStderr ( sampleStderr ) ;
97
- assert . deepStrictEqual ( actual ?. name , 'SyntaxError' ) ;
98
- assert . deepStrictEqual ( actual ?. classification , 'ERROR' ) ;
99
- assert . deepStrictEqual ( actual ?. message , 'test error message' ) ;
100
- assert . deepStrictEqual ( actual ?. resolution , 'test resolution' ) ;
101
- } ) ;
97
+ const actual = AmplifyError . fromStderr ( sampleStderr ) ;
98
+ assert . deepStrictEqual ( actual ?. name , 'SyntaxError' ) ;
99
+ assert . deepStrictEqual ( actual ?. classification , 'ERROR' ) ;
100
+ assert . deepStrictEqual ( actual ?. message , 'test error message' ) ;
101
+ assert . deepStrictEqual ( actual ?. resolution , 'test resolution' ) ;
102
+ } ) ;
102
103
103
- void it ( 'deserialize when string is encoded with single quote and has double quotes escaped in between' , ( ) => {
104
- const sampleStderr = `some random stderr
104
+ void it ( 'deserialize when string is encoded with single quote and has double quotes escaped in between' , ( ) => {
105
+ const sampleStderr = `some random stderr
105
106
${ util . inspect ( {
106
107
serializedError :
107
108
'{"name":"SyntaxError","classification":"ERROR","options":{"message":"paths must start with \\"/\\" and end with \\"/*","resolution":"test resolution"}}' ,
108
109
} ) }
109
110
and some after the error message
110
111
` ;
111
- const actual = AmplifyError . fromStderr ( sampleStderr ) ;
112
- assert . deepStrictEqual ( actual ?. name , 'SyntaxError' ) ;
113
- assert . deepStrictEqual ( actual ?. classification , 'ERROR' ) ;
114
- assert . deepStrictEqual (
115
- actual ?. message ,
116
- 'paths must start with "/" and end with "/*'
117
- ) ;
118
- assert . deepStrictEqual ( actual ?. resolution , 'test resolution' ) ;
119
- } ) ;
112
+ const actual = AmplifyError . fromStderr ( sampleStderr ) ;
113
+ assert . deepStrictEqual ( actual ?. name , 'SyntaxError' ) ;
114
+ assert . deepStrictEqual ( actual ?. classification , 'ERROR' ) ;
115
+ assert . deepStrictEqual (
116
+ actual ?. message ,
117
+ 'paths must start with "/" and end with "/*'
118
+ ) ;
119
+ assert . deepStrictEqual ( actual ?. resolution , 'test resolution' ) ;
120
+ } ) ;
120
121
121
- void it ( 'deserialize when string is encoded with double quote and has double quotes string in it' , ( ) => {
122
- const sampleStderr = `some random stderr
122
+ void it ( 'deserialize when string is encoded with double quote and has double quotes string in it' , ( ) => {
123
+ const sampleStderr = `some random stderr
123
124
serializedError: "{\\"name\\":\\"SyntaxError\\",\\"classification\\":\\"ERROR\\",\\"options\\":{\\"message\\":\\"test error message\\",\\"resolution\\":\\"test resolution\\"}}"
124
125
and some after the error message
125
126
` ;
126
- const actual = AmplifyError . fromStderr ( sampleStderr ) ;
127
- assert . deepStrictEqual ( actual ?. name , 'SyntaxError' ) ;
128
- assert . deepStrictEqual ( actual ?. classification , 'ERROR' ) ;
129
- assert . deepStrictEqual ( actual ?. message , 'test error message' ) ;
130
- assert . deepStrictEqual ( actual ?. resolution , 'test resolution' ) ;
131
- } ) ;
127
+ const actual = AmplifyError . fromStderr ( sampleStderr ) ;
128
+ assert . deepStrictEqual ( actual ?. name , 'SyntaxError' ) ;
129
+ assert . deepStrictEqual ( actual ?. classification , 'ERROR' ) ;
130
+ assert . deepStrictEqual ( actual ?. message , 'test error message' ) ;
131
+ assert . deepStrictEqual ( actual ?. resolution , 'test resolution' ) ;
132
+ } ) ;
132
133
133
- void it ( 'deserialize when string has single quotes in between' , ( ) => {
134
- const sampleStderr = `some random stderr
134
+ void it ( 'deserialize when string has single quotes in between' , ( ) => {
135
+ const sampleStderr = `some random stderr
135
136
${ util . inspect ( {
136
137
serializedError :
137
138
'{"name":"SyntaxError","classification":"ERROR","options":{"message":"Cannot read properties of undefined (reading \'data\')","resolution":"test resolution"}}' ,
138
139
} ) }
139
140
and some after the error message
140
141
` ;
141
- const actual = AmplifyError . fromStderr ( sampleStderr ) ;
142
- assert . deepStrictEqual ( actual ?. name , 'SyntaxError' ) ;
143
- assert . deepStrictEqual ( actual ?. classification , 'ERROR' ) ;
144
- assert . deepStrictEqual (
145
- actual ?. message ,
146
- `Cannot read properties of undefined (reading 'data')`
147
- ) ;
148
- assert . deepStrictEqual ( actual ?. resolution , 'test resolution' ) ;
142
+ const actual = AmplifyError . fromStderr ( sampleStderr ) ;
143
+ assert . deepStrictEqual ( actual ?. name , 'SyntaxError' ) ;
144
+ assert . deepStrictEqual ( actual ?. classification , 'ERROR' ) ;
145
+ assert . deepStrictEqual (
146
+ actual ?. message ,
147
+ `Cannot read properties of undefined (reading 'data')`
148
+ ) ;
149
+ assert . deepStrictEqual ( actual ?. resolution , 'test resolution' ) ;
150
+ } ) ;
151
+ } ) ;
152
+
153
+ void describe ( 'V2 deserialization' , ( ) => {
154
+ void it ( 'deserialize when string is encoded with single quote' , ( ) => {
155
+ const sampleStderr = `some random stderr
156
+ serializedError: '${ Buffer . from (
157
+ '{"name":"SyntaxError","classification":"ERROR","options":{"message":"test error message","resolution":"test resolution"}}'
158
+ ) . toString ( 'base64' ) } ',
159
+ and some after the error message
160
+ ` ;
161
+ const actual = AmplifyError . fromStderr ( sampleStderr ) ;
162
+ assert . deepStrictEqual ( actual ?. name , 'SyntaxError' ) ;
163
+ assert . deepStrictEqual ( actual ?. classification , 'ERROR' ) ;
164
+ assert . deepStrictEqual ( actual ?. message , 'test error message' ) ;
165
+ assert . deepStrictEqual ( actual ?. resolution , 'test resolution' ) ;
166
+ } ) ;
167
+
168
+ void it ( 'deserialize when string is encoded with double quote' , ( ) => {
169
+ const sampleStderr = `some random stderr
170
+ serializedError: "${ Buffer . from (
171
+ '{"name":"SyntaxError","classification":"ERROR","options":{"message":"test error message","resolution":"test resolution"}}'
172
+ ) . toString ( 'base64' ) } ",
173
+ and some after the error message
174
+ ` ;
175
+ const actual = AmplifyError . fromStderr ( sampleStderr ) ;
176
+ assert . deepStrictEqual ( actual ?. name , 'SyntaxError' ) ;
177
+ assert . deepStrictEqual ( actual ?. classification , 'ERROR' ) ;
178
+ assert . deepStrictEqual ( actual ?. message , 'test error message' ) ;
179
+ assert . deepStrictEqual ( actual ?. resolution , 'test resolution' ) ;
180
+ } ) ;
181
+
182
+ void it ( 'deserialize when string is encoded with back ticks' , ( ) => {
183
+ const sampleStderr = `some random stderr
184
+ serializedError: \`${ Buffer . from (
185
+ '{"name":"SyntaxError","classification":"ERROR","options":{"message":"test error message","resolution":"test resolution"}}'
186
+ ) . toString ( 'base64' ) } \`,
187
+ and some after the error message
188
+ ` ;
189
+ const actual = AmplifyError . fromStderr ( sampleStderr ) ;
190
+ assert . deepStrictEqual ( actual ?. name , 'SyntaxError' ) ;
191
+ assert . deepStrictEqual ( actual ?. classification , 'ERROR' ) ;
192
+ assert . deepStrictEqual ( actual ?. message , 'test error message' ) ;
193
+ assert . deepStrictEqual ( actual ?. resolution , 'test resolution' ) ;
194
+ } ) ;
149
195
} ) ;
150
196
} ) ;
151
197
0 commit comments