Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to verify zip response from get #686

Open
aptiway-dev-app opened this issue Nov 24, 2020 · 0 comments
Open

unable to verify zip response from get #686

aptiway-dev-app opened this issue Nov 24, 2020 · 0 comments

Comments

@aptiway-dev-app
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant