September 2018
Intermediate to advanced
764 pages
20h 6m
English
First, inside the /home/dli/.d4nyll/.beja/final/code/9/src/handlers/users/create/index.js file, change the return undefined; statement to propagate the error down the promise chain:
return res.json({ message: err.message }); } throw err; }).catch(() => { res.status(500);
Then, add unit tests to src/handlers/users/create/index.unit.test.js to cover this missed scenario:
const generateCreateStubs = { success: () => stub().resolves({ _id: USER_ID }), genericError: () => stub().rejects(new Error()), validationError: () => stub().rejects(new ValidationError(VALIDATION_ERROR_MESSAGE)),};...describe('createUser', function () { ... describe('When create rejects with an instance of Error', function () { beforeEach(function ...Read now
Unlock full access