Jawad Sefiani
11/28/2023, 2:21 PMconst formData = new FormData();
formData.append(
'meta',
JSON.stringify({
some_key: "some_value",
}),
);
formData.append('file', createFile());
provider
.given('I have file with more than 1000 values')
.uponReceiving('a request to create a rule using a file with more than 1000 values')
.withRequest({
method: 'POST',
path: '/rules',
body: formData,
headers: {
'Content-Type': 'multipart/form-data',
},
})
.willRespondWith({
status: 201,
body: mockedResponse,
contentType: 'application/json',
});
return provider.executeTest(async (mockServer) => {
<http://axiosInstance.post|axiosInstance.post>("/rules", formData, {
baseURL: mockServer.url,
headers: {
'Content-Type': 'multipart/form-data',
},
})
// some assertion
});
I'm getting the following error:
Mock server failed with the following mismatches:
0) The following request was incorrect:
POST /rules
1.0 Mismatch with header 'Content-Type': Expected value 'multipart/form-data' at index 1 but was missing (actual has 1 value(s))
1.1 Expected a body of 'application/json' but the actual content type was 'multipart/form-data;boundary=--------------------------087154011299288967847178'
Axios adds this annoying boundary value to the content type but Pact doesn't know about this value. How can I solve this?Jawad Sefiani
11/28/2023, 8:18 PMMock server failed with the following mismatches:
0) The following request was expected but not received:
Method: POST
Path: /rules
Headers:
Content-Type: multipart/form-data;, multipart/form-data;
Body: {}... (2 length)
Jawad Sefiani
11/28/2023, 11:02 PMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Jawad Sefiani
12/06/2023, 10:59 AMMatt (pactflow.io / pact-js / pact-go)
body
expectation.