So I'm a bit confused about supertest. I'm currently attempting to write a test suite for the back end of a web portal using Mocha and Supertest, and I'm very much still learning the ropes. I've been testing off of a simple HTTPS server that I initiate with javascript and node.js, then running mocha tests with supertest assertions.
All my GET tests work well- if I attempt to get a file that I know is there, it completes the 200 expect assertion. If I attempt to get a file that I know is invalid, it completes the 404 expect assertion. However, when I run PUT, POST or DEL as functions of my supertest object, it doesn't seem to do anything. For example:
it('should delete json', function(done){
request
.del('/files/package.json')
.end(function(err, res){
if (err) return done(err);
done();
});
});
does not actually delete the file, yet passes the test. If I run a 404 expect assertion after the DEL, the test then fails.
I am confused whether I'm just completely missing something from my code or if the commands don't do what I think they do, or if I've just misunderstood how this testing framework works. Sorry if it's a stupid question, very new at this.
via user3817846
No comments:
Post a Comment