I need some help to resolve my problem with testing on nodejs codes. I'm using mocha and supertest. I'm confused with the implementation in supertest. I don't know to resolved it. I'm trying to automate downloading a file.
`describe('GET /entry/:entryId/file/:id/download', function(){
it('should pass download function', function(done){
this.timeout(15000);
request(app.webServer)
.get('/entry/543CGsdadtrE/file/wDRDasdDASAS/download')
.set('Authorization', 'Bearer eyJ0eXAiOiJKV1QiLCJhbGco')
.expect(200)
.end(function(err, res){
if (err) return done(err);
console.log(err, res);
done();
});
});
});
Typescript users, who are facing this error, check two things:
module.exports = app
(thanks to @Collin D)import * as app from "./app"
instead of wrong
import app from "./app"
I received a similar error from mocha when testing an express app. Full text of error:
I fixed it by adding this to my express server.js, i.e. export the server object
I was facing same problem, above solution didn't work for me, some one in my shoes kindly follow this guy's
exports in server.js should be
If you have multiple modules than use es6 feature
my package.json for version cross ref..