When I run the tests on my Exercise tracker it consistently fails the test on the /api/exercise/add route and occasionally fails the test on the /api/exercise/log route, even when I haven’t changed the code under that route between tests.
app.post('/api/exercise/add', async (req, res) => {
try {
let { userId, description, duration, date } = req.body;
const user = await User.findById(userId, '_id username').lean();
if (!date) {
date = dayjs().format('YYYY-MM-DD');
}
const activity = new Activity({
userId: userId,
description: description,
duration: duration,
date, date
})
activity.save();
user.date = date
user.duration = duration;
user.description = description;
res.json(user)
}
catch (err) {
console.error(err);
}
})
this is the code for the /add route and it seems to work properly when I look at the response page.
Is there anything obvious that I’ve overlooked?
You can find the app here https://hidden-dusk-88977.herokuapp.com/
and a userId that has a decent amount of exercises logged is 5fced7e87e1038135b4bfef1