+function unwrapBodyOrDecodeToJSON <T> (test: request.Test): Promise<T> {
+ return test.then(res => {
+ if (res.body instanceof Buffer) {
+ return JSON.parse(new TextDecoder().decode(res.body))
+ }
+
+ return res.body
+ })
+}
+
+function unwrapTextOrDecode (test: request.Test): Promise<string> {
+ return test.then(res => res.text || new TextDecoder().decode(res.body))
+}
+