jaydenseric / apollo-upload-client

A terminating Apollo Link for Apollo Client that fetches a GraphQL multipart request if the GraphQL variables contain files (by default FileList, File, or Blob instances), or else fetches a regular GraphQL POST or GET request (depending on the config and GraphQL operation).
https://npm.im/apollo-upload-client
1.53k stars 156 forks source link

Strategy for writing automatic unit tests #276

Closed that-one-arab closed 2 years ago

that-one-arab commented 2 years ago

I was wondering if there was a good strategy to write tests that automatically selects a local image/s, then sends an HTTP request to the server. I tried doing it server-side but failed because I couldn't manage to transfer the image to a blob and send it (I always received the image's mimetype as application/octal-stream) Maybe I missed some tips while researching, I hope this is an appropriate place to ask this question, and if it is, I hope I get some insight on how to do it.

jaydenseric commented 2 years ago

Are you trying to test your GraphQL API processes GraphQL multipart request mutations correctly, or are you trying to test your front end project code? If it's the first, you shouldn't use Apollo Client or this package; just make the requests manually. You can use use fetch (via node-fetch) and FormData (via formdata-node).