ivan's avatar
Level 1

Testing responses for downloads and inline images

I'm currently using the Laravel and REST api modules in Codeception to test and the tools have been great so far.

I have several routes that return either download or inline images and I currently don't have a strong way of testing, other than checking no errors have occurred.

Ideally I would like to perform a file compare with the result.

Has anyone approached this issue and have any tips on taking this forward?

Thanks

0 likes
3 replies
RachidLaasri's avatar

I am not sure i understood what you are trying to do, but i you can test if the downloaded file exist in the folder.

ivan's avatar
Level 1

sure, this is my intent but do you know the syntax in codeception to call a REST API where the result is a binary? My testing so far checks the JSON response and HTTP status code. I don't have any reference material on how to handle binaries.

ivan's avatar
Level 1

For anyone that stumbles across this in a search, at the moment I am inspecting the response headers. I assert the following are populated correctly:

content-disposition content-length content-type

This is inference as opposed to explicit. When time permits, I'll look at what it takes to perform a binary compare on the downloaded or inline image/file

1 like

Please or to participate in this conversation.