I'm using express, mongoose, cloudinary, multer to set everything up but whenever I run tests, I get a server error (500) because the file I'm uploading doesn't exist. Everything works so I don't think this is a middleware issue - when I test with postman, I get the correct errors and correct return statements.routerrouter.post('/', upload.single('image'), (req, res) => { // stuff goes here } testingit('should add a new POST', function() { return chai.request(app) .post('/posts') .type('form') .field('text', 'text') .attach('image', './test/test_image.JPG', 'test_image.JPG') .then(function(res) { expect(res).to.have.status(200); }) }) I'm also testing what happens when required fields are missing but I can't even get this test to pass :/
Submitted December 26, 2019 at 11:30AM by RadiantImplement7
No comments:
Post a Comment