This what you’re after: <https://github.com/pact-f...
# pact-js
m
m
It just might be! Thank you so much!
👍 1
Hello again! Thank you for your recent response. I've been trying to implement a consumer tests with this function, but it eludes me how this function is meant to be used, as we don't have an example available, neither in the official documentation nor in the entire rest of the internet. Please forgive me for being arduous about this, but I would like to request some additional help in understanding this function and whether it is the right one to use in the first place. For clarification, the request I would like to write a test for looks something like this:
Copy code
curl --location '<http://localhost:3000/endpoint>' \
--form 'file=@"/home/user/pictures/testImage.jpeg"' \
--form 'type="logo"'
with headers of:
Copy code
Content-Type: multipart/form-data; boundary=<calculated when request is sent>
Content-Length: <calculated when request is sent>
From your understanding of the framework implementation, would this function apply in this case? As always, any help is appreciated. Thank you!
Additionally, I would like to ask some clarifications on the arguments required when using the function: public withRequestMultipartFileUpload( req: V3Request, contentType: string, file: string, mimePartName: string ){...} V3Request: How would a body have to be structured for a given multi-part file upload request? Would the solution provided by YOU54F in https://github.com/pact-foundation/pact-js/issues/277#issuecomment-487939601 apply, or would it be json? file: How is the file data injected here? Should it be the path to the file or a buffer / blob / any other object converted into a string? I'd be happy to provide an example of how I've been trying to use it, as I'm quite stumped at this point. No matter how I configure the test, I keep running into different error-massages from the pact-framework. When everything is configured as I think it is expected to be, I still run into the following error:
Copy code
PactffiWithMultipartFile: invalid multipart body specified:with_multipart_file: This Pact can not be modified, as the mock server has already started
Again, thank you for your help!
I think I forgot to make this response public to channel. Any suggestions for the last two messages? 🙂 Thanks a bunch. <3
t
I don’t know, I’m afraid. My knowledge of pact-js stops at v2. However, the error suggests that the mock server is being started before calling the multipart function. What order are you calling the functions in, and can you change it?