Unit Testing Next.js Router - useRouter - React.js Testing Tutorial #9

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


Join the channel to support my content:

Follow me on:

Timeline:
00:00 Introduction
00:06 Why useRouter() is null in unit tests?
02:10 Common online solution to mock useRouter
02:43 Create Mock Router function
04:35 How to unit test useRouter by providing RouterContext Provider
06:48 Link and useRouter unit-test
11:32 Spec files side by side with page components

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

I spent 1 to 2 hours trying to get this to work and your very clear explanations made it work in under 10 minutes. Thank you !

todarfclips
Автор

Your teaching style is so good. Thank you for sharing. Your channel deserve more subscribers

sultanalmuhon
Автор

Thanks for all the material. This serie is by far the best on youtube. 🍻

gonwms
Автор

Again, you uploaded a video that explained exactly what I was looking for. And this in an extremely professional way, there are unfortunately too many youtubers who give imprecise information

marc-andrequintal
Автор

I have seen many jest mocks for router in the nextjs issues but this one is the best so far.

kevinzunigacuellar
Автор

Bruno the man, never change man I love that you explain the reasoning (going to source code of nextjs).

frozen_tortus
Автор

Missing your content Bruno. Stay safe.

oz
Автор

Your videos are very explanatory and this series helped me to understand and start working on react unit testing. It would be a great help if you explain how to test 3rd party libraries like AG-GRID in react.

petitexplorer
Автор

Thanks a lot for your hard work Bruno, everything you do is simply awesome :)

bojantest
Автор

This man has solved my problem in a simple effective manner compared to the collaborator's - thanks

Allyourneedsmet
Автор

Great explanation, Thank you for the video, normally I use the jest.mock approach, but testing with dynamic data was a bit difficult using jest.mock approach. Thanks to your video I was able to understand this approach, it's easy and versatile. 🤠✌
and thanks for mentioning the "RouterContext" import for an older version. it made things easier.

safuvankp
Автор

Thank you, this saved me after 2 hours of googling

visjenl
Автор

I wish you all the best brother. You have been away for sometimes. Hope all is good.

oz
Автор

Salvou minha vida irmão! Não encontrava solução pra esse problema de jeito nenhum, e me deparei com seu vídeo. Parabéns pelo vídeo.

othokomatsu
Автор

Fantastic video series - thank you for sharing your expertise!

yumatanaka
Автор

You are amazing man ! please don't stop ! ps: maybe some graphql in the future

salaheddine
Автор

Thanks for the great work! It helped me a lot.

juliaramosguedes
Автор

Hey Bruno, missing your videos. <3

LucianoSoares
Автор

Hope you are well! Some time passed after you posted your last video! 😰

codernerd
Автор

Thanks. What about redux unit testing in Next JS

RdozeTV