Nest.js Unit Testing | Best Practices + MongoDB

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

This is criminally underrated content....I had a hard time understanding mocks...and this is a very clear and crisp explanation....by far the best I've seen

pranjalwalia
Автор

man, you deserve a million likes. A very high quality of content, congrats! You helped me a lot!

devshikamaru
Автор

Oh man your explanation jest testing is the most understandable what I have ever seen before

dmytrohaponov
Автор

You sir are my new hero. Sooo much was unveiled here to help me get on track w/ Nest, testing and mocking. Thank you 🙏

CjTaylor
Автор

The reason why we have to write two different mocks for find() and create() is that:
- Look at how all the other methods (such as findOne(), findOneAndUpdate() etc.) take in different parameters; but the save method doesn't. The save() method is called upon the mongo document itself instead of the mongo model. The save() simply creates an instance of the mongo document. This is why we have to test the save() method on the Prototype of the model.

hasibulhossainrasheeq
Автор

Absolutely incredible content!! I unfortunately don't use Mongo in my project but I still learned so much.

I learned so much. If you had a course, I would buy it haha.

With that said, it would be totally amazing if you could make a video on Prisma/Postgres ;)

christoffer
Автор

Hey bro! Awesome content. Wishing you all the best for many more subscribers, btw I am your 610th subscriber.

bhaskarkatragadda
Автор

Master Michael Guay, excellent explanation about mocks, there are details that you don't really find in other videos

fabianmateobeltranvalencia
Автор

amazing video, great explanation about mock, i was struggling with that. Subscribed!

nguyenlequang
Автор

Exactly what I've been looking for. Thank you!

kousthubraja
Автор

Thank you for this video. You just got your 749th subscriber 🥳

davidpopoola
Автор

The last problem is related to useClass and useValue from Jest, that is why it complains when you try to instantiate a new entity model.

I notice this when I started the repository test and I used useValue instead of useClass. Jest told me he could find the function “findOne” I was trying to spy on.

I don't know why this happens, but my guess is that useClass creates an instance of the userModel, and useValue does not.

Edit: forgot to say, this was a wonderful class about a topic that I had no knowledge before. Unit testing is brand new to me, and I got the gist of it with this video. Thanks for your work!
ヾ(^▽^*)))

TrunoBR
Автор

This video is a gem! Thank you so much man.

dominicfernandes
Автор

Sir, you have a lovely, great and understandable explanation, please keep explane in this way, please provide us more videos about NestJs, Thank you very mush

ayoubguismi
Автор

very easy to follow and clean video, thank you very much!

aslop
Автор

Real good. Commenting to promote in youtube algorithms

eduardboiko
Автор

if i need to pass an invalid mock so that the route returns an exception, what should i do?

ThiagoBussola
Автор

Awesome explanations, Dude. Thank you!!!

RoVBonfim
Автор

why don't you use overrideprovider?

pelaoinfo
Автор

Really nice video! There is not much content specifically on nestjs + jest+ mongo. I just didn't understand some things regarding types:

1) If the main goal is to test unit functionalities, inputs and outputs types, is it preferable to define the userStub as UserDocument instead of User type? Since all mongo related fields and methods come from Document type, including _id (ObjectId) field;

I tried defining userStub as UserDocument but as it is a Type not exactly a Class I wasn't able to instantiate it with mocked values. How would you do it?

m__c_s