forked from kaievns/express-yields
-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
I've changed one of the tests to match the same approach I'm using in my application but it's not being handled:
const multer = require('multer');
const storage = multer.diskStorage({
destination(req, file, cb) {
cb(null, '/tmp/my-uploads');
},
filename(req, file, cb) {
const uniqueSuffix = `${Date.now()}-${Math.round(Math.random() * 1E9)}`;
cb(null, `${file.fieldname}-${uniqueSuffix}`);
},
});
const uploader = multer({
storage,
preservePath: true,
limits: { fileSize: 999 },
}).array('file');
it('propagates routes errors to error handler in Router with multer', () => {
const app = express();
const router = new Router();
router.post('/test', async (req, res, next) => {
uploader(req, res, (err) => {
throw new Error('error');
});
});
app.use('/upload', router);
app.use((err, req, res, next) => {
res.status(495);
res.end();
});
return supertest(app)
.post('/upload/test')
.attach('file', `${__dirname}/.travis.yml`)
.expect(495);
});When I execute the test, I'm only receiving the crash "error" in the terminal, not the expected status from the handler!
Thanks for the help
code0monkey1
Metadata
Metadata
Assignees
Labels
No labels