Testing Express REST API With Jest & Supertest

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


📚 Concepts & technologies covered
- Testing a REST API end-to-end with Supertest & mongodb-memory-server
- Mocking services
- Testing from the controller to the service

🌎 Follow me here:
Рекомендации по теме
Комментарии
Автор

1. 0:00 - Intro
2. 2:00 - Getting started & Setup
3. 5:10 - Creating test file for 'products'
4. 8:06 - Adding test command and running it
5. 9:24 - Refactoring in order to implement supertest
6. 15:50 - mongodb-memory-server (Author recommends mocking the service instead, this is demonstrated in chapter 10. )
7. 18:47 - Adding more tests
8. 25:22 - JWT
9. 29:54 - .skip and .only flags for jest
10. 30:54 - Test file for 'Users' (The authors recommended way: mocking out service instead of mongodb-memory-server)
11. 36:26 - Mocking out and 'spying on' userService
12. 41:27 - Running the first User test
13. 43:57 - Clearing mocks in between tests
14. 46:05 - Reseting mocks in between tests
15. 47:16 - Test creation of user access token (Last test in the tutorial)
16. 52:34 - Bonus: Jest extension for VSCode

mikda
Автор

This channel is a gem! I appreciate that you cover important and practical topics (i.e testing, TS) in great detail. I've seen some videos on the 2 topics mentioned above but not as as it pertains to Nodejs. Thank you and you definitely deserve more views/subscribers.

jritzeku
Автор

THANK YOU SO MUCH for making this video. I've been looking for a compare and contrast of mongo-memory-server and mocking services for quite awhile!

narissatsuboi
Автор

I really like your use of multiple describe blocks here. I recently implemented something very similar for a project and have found having these tests is really helpful when refactoring. Thanks for the content!

eyeiozm
Автор

Best tutorial on YouTube so far... and I've been searching for months

mohamedyoussef
Автор

Great testing video. Appreciate your time and effort with it. Found your channel a few weeks ago and have slowly been making my way through all the videos. :)

chrisjames
Автор

Hi Tom! Your authentication API video with typegoose and zod helped me tremendously. I know i will learn a lot from this, so Thank you for making this video!

dumbledoornguyen
Автор

Thanks for your efforts Tom. Love the video

ayushpaharia
Автор

Thanks for the awesom video. You made my TDD weekend fun.

salmanrana
Автор

This series is the best tutorial I've been following, thank you very much it is gold

wralith
Автор

Amazing tutorials as always, love your Typescript/Mongoose/Express series

LifeShortBeNatty
Автор

This is the best tutorial ever, thank you Tom!

jxlim
Автор

This is awesome that your are expanding the same API. I hope this series keeps going!

Scetils
Автор

This video is exacly what I need ATM.
ChaiHttp just decided to stop working, also it have problems with ES6 import modules, so I really needed to learn how to use Supertest, also I learned a lot of good practices in this video. Dude, this video is a complete GOLD.

gustavoandr
Автор

I am so genuinely excited for this you sir are a beacon of light in the coding world lol starting it now👌🏽💯

tyengineer
Автор

Thank you very much, this is exactly what I need for my practice :> There are extremely few videos about Jest comparing to Cypess. Luckily I found yours :>

huyennguyenmaingoc
Автор

I'm really greatful for such tutorial. Before knowing about all taht stuuf, I asked myself : "How cna I test my API efficiently, with the most detailed tests possible and reproductibility ?". I almost started to cre&te tests using bash & curl, and starting my server as a daemon. I knew it was not the solution, so I didn't started yet. Thanks to your video, I know the correct way now.

Ximaz-
Автор

Thank you so much man, learning alot from you.

Jalak-govm
Автор

I was absolutely clueless on how to mock my own functions. thank you so much

pscoriae
Автор

Good video! I watched it for the second time.

good-dev-student