forwardemail / forwardemail/supertest
unable to verify zip response from get
- Dominant language
- JavaScript
- Stars
- 14.4k
- Forks
- 782
- PR merge metrics
- No merged PRs in 30d
Description
We have written NodeJS based express application. REST API is defined as following:
```
router.get('/module/:id/', async (req, res ) => {
try {
var moduleid = req.params.id
const module = await ModuleMaster.findById(moduleid)
if(!module || !module.modulefile){
throw new Error('Module does not exist')
}
res.set('Content-Type','application/zip')
res.send(module.modulefile)
} catch (error) {
res.status(404).send(error.Message)
}
})
```
Above function is successfully returning file is being tested in browser and postman.
As part of automation, we have written following Jest script to test the functionality of receiving file.
```
const request = require('supertest')
responseFromFileFAPI = await request(app).get('/module/1')
.expect(200)
expect(responseFromFileFAPI.body).not.toBeNull()
expect(responseFromFileFAPI.body.Buffer)
```
All above expect are passing however I am not sure how can I convert the response to zip format so that I can use it to compare with original file?
Contributor guide
Assessment
This issue has not been assessed yet.