Skip to content

Commit 5416ed0

Browse files
authored
Merge pull request #1441 from blackflux/dev
[Gally]: master <- dev
2 parents 3842581 + 8adf6d3 commit 5416ed0

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

src/modules/request-recorder.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ export default (opts) => {
235235

236236
if (anyFlagPresent(['magic', 'response'])) {
237237
const responseBody = tryParseJson([
238-
healSqs
238+
healSqs,
239+
(_, b) => (b instanceof Buffer ? b.toString('hex') : b)
239240
].reduce(
240241
(respBody, fn) => fn(requestBodyString, respBody, scope, req),
241242
interceptor.body

test/modules/request-recorder.spec.js

+11
Original file line numberDiff line numberDiff line change
@@ -672,5 +672,16 @@ describe('Testing RequestRecorder', { useTmpDir: true, timestamp: 0 }, () => {
672672
}), { heal: 'magic' });
673673
expect(expectedCassette).to.deep.equal([{ ...fixture('post')[0], body: 'NEW' }]);
674674
});
675+
676+
it('Testing hex response not changed', async ({ fixture }) => {
677+
const cassettePath = path.join(tmpDir, cassetteFile);
678+
fs.smartWrite(cassettePath, fixture('gzip'));
679+
const { expectedCassette } = await nockRecord(() => axios({
680+
method: 'POST',
681+
url: 'https://test.com/',
682+
data: 'DATA'
683+
}), { heal: 'response' });
684+
expect(expectedCassette).to.deep.equal([{ ...fixture('gzip')[0] }]);
685+
});
675686
});
676687
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[
2+
{
3+
"scope": "https://test.com:443",
4+
"method": "POST",
5+
"path": "/",
6+
"body": "DATA",
7+
"status": 200,
8+
"reqheaders": {
9+
"accept": "application/json, text/plain, */*",
10+
"content-length": "4",
11+
"content-type": "application/x-www-form-urlencoded",
12+
"host": "test.com",
13+
"accept-encoding": "gzip, compress, deflate, br",
14+
"user-agent": "axios/1.7.9"
15+
},
16+
"responseIsBinary": true,
17+
"rawHeaders": [
18+
"Content-Encoding",
19+
"gzip",
20+
"Content-Type",
21+
"application/json"
22+
],
23+
"response": "1f8b08000000000002035d93d96e83301045ffc57d459597197b9c5fa92a64c0595412249a449522febdb6c33209bc202f67eedc3b3c443bf4c3f82b765f0f31c64eece4a7f7563aaac431fe899df8d8c7f436a2124d7f8b659fc028a8c4618cf1b25d98aa95401e94da0811baa60d8ce0bc56e81881904803233892c6eb95d03a6f9c670470808a01d059708a01701639033c7a49c40068f2c30909202d2340d1b4121c5a422ec180979a0120790086018c324ee30a4089122207c85c81119e17a6ef4a847b1cc321d6fded7cba844bfbec39f98cc9d56e288bd77a89ee21eea7664c2bf97389208b515b04521b2d5971a5113cab5d4ae35489f3ed1abbba3f1d8e1ce75e67a26d1a1f782f96b4416ea7cbfc05c740cbc11914229135dc14ca07782e25a8449a7bacbb30fe30a029c9af402b3569f5d2681a46eeb24a415a0e7cef957c1ebecd3a6cf70d1f1d9786d772ef48296737efde044229b8090c4086ff4e3ac7ceadd3c5a2699afe01f4f916539d030000"
24+
}
25+
]

0 commit comments

Comments
 (0)