@@ -85,67 +85,113 @@ and some after the error message
8585 assert . deepStrictEqual ( actual ?. cause ?. message , testError . cause ?. message ) ;
8686 } ) ;
8787
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
9091 ${ util . inspect ( {
9192 serializedError :
9293 '{"name":"SyntaxError","classification":"ERROR","options":{"message":"test error message","resolution":"test resolution"}}' ,
9394 } ) }
9495and some after the error message
9596 ` ;
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+ } ) ;
102103
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
105106 ${ util . inspect ( {
106107 serializedError :
107108 '{"name":"SyntaxError","classification":"ERROR","options":{"message":"paths must start with \\"/\\" and end with \\"/*","resolution":"test resolution"}}' ,
108109 } ) }
109110and some after the error message
110111 ` ;
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+ } ) ;
120121
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
123124 serializedError: "{\\"name\\":\\"SyntaxError\\",\\"classification\\":\\"ERROR\\",\\"options\\":{\\"message\\":\\"test error message\\",\\"resolution\\":\\"test resolution\\"}}"
124125and some after the error message
125126 ` ;
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+ } ) ;
132133
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
135136 ${ util . inspect ( {
136137 serializedError :
137138 '{"name":"SyntaxError","classification":"ERROR","options":{"message":"Cannot read properties of undefined (reading \'data\')","resolution":"test resolution"}}' ,
138139 } ) }
139140and some after the error message
140141 ` ;
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+ } ) ;
149195 } ) ;
150196} ) ;
151197
0 commit comments