Skip to content

Commit 731d664

Browse files
committed
test: cloning some data to another var to prevent test corruption
1 parent 02356b6 commit 731d664

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

test/requests.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,16 @@ fixtures.cli.forEach(function (cli) {
4545
err.should.be.null()
4646
}
4747

48+
// Clone the fixture we're testing against to another object because for multipart/form-data cases we're
49+
// deleting the header, and if we don't clone the fixture to another object, that deleted header will cause
50+
// other tests to fail because it's missing where other tests are expecting it.
51+
const fixture = JSON.parse(JSON.stringify(fixtures.requests[request]))
52+
4853
// make an exception for multipart/form-data
49-
if (fixtures.requests[request].headers) {
50-
fixtures.requests[request].headers.forEach(function (header, index) {
54+
if (fixture.headers) {
55+
fixture.headers.forEach(function (header, index) {
5156
if (header.name === 'content-type' && header.value === 'multipart/form-data') {
52-
delete fixtures.requests[request].headers[index]
57+
delete fixture.headers[index]
5358
}
5459
})
5560
}
@@ -59,7 +64,7 @@ fixtures.cli.forEach(function (cli) {
5964
har.log.entries[0].should.have.property('request')
6065
// BUG: Mockbin returns http url even when request is for https url
6166
if (request !== 'https') {
62-
har.log.entries[0].request.should.containDeep(fixtures.requests[request])
67+
har.log.entries[0].request.should.containDeep(fixture)
6368
}
6469
done()
6570
})

0 commit comments

Comments
 (0)