Тёмный

ExpressJS - Jest & Unit Testing 

Anson the Developer
Подписаться 56 тыс.
Просмотров 26 тыс.
50% 1

Support the Channel:
Become a Member: www.youtube.co...
Become a Patreon: / stuyy
Buy me a Coffee: ko-fi.com/anson
Donate on Streamlabs: streamlabs.com...
Donate on PayPal: paypal.me/anso...
Connect with me:
Twitter: / ansonthedev
Discord: / discord
GitHub: github.com/stuyy
Twitch: / stuy

Опубликовано:

 

30 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 19   
@adamsackfield589
@adamsackfield589 2 года назад
Absolutely the best video I’ve found on testing an API. I plan on going back to the start and following along to really get a grasp on testing. Would be even better if you implement a little E2E testing.
@rady6546
@rady6546 Год назад
This is integration testing not unit because unit testing haven't side effect
@marshelaillon
@marshelaillon 11 месяцев назад
What vsc theme are you using?
@UdayKiranK-t9q
@UdayKiranK-t9q 2 месяца назад
thank you for this tutorial, helped me understand the fundamentals of unit testing
@lovelesslol
@lovelesslol 2 года назад
👍🙂 Thanks that will help a lot.
@learningforever2531
@learningforever2531 Год назад
Thanks for the sharing, Im just confusing why the object {id: 1, email: "..."} is wrapped in parenthesis ? Since I read the documentation in jest mockFn.mockImplementationOnce(fn) // where fn could be () => {// the code} So hope you or everyone could share the reason Here is the code in your video: User.mockImplementationOnce(() => ({id: 1, email: "..."} ))
@ansonthedev
@ansonthedev Год назад
Without the parenthesis, everything inside the curly braces, { }, would need to be statements. The parenthesis wrapping the curly braces indicates the return value is an object. It's a shorthand for doing this: () => { return { ... } }
@pandagamedev1177
@pandagamedev1177 2 месяца назад
what theme of vs did you use in this video
@stalkingplagiarist
@stalkingplagiarist Год назад
Another awesome video, best explanation on testing I found so far on YT 🤘🤘🤘
@hashanhemachandra4832
@hashanhemachandra4832 2 года назад
Thanks so much for this tutorial Anson! Like Adam said, This is the best explanatory video I've ever seen on the internet on JEST testing! Love from Sri Lanka!
@learningforever2531
@learningforever2531 Год назад
Hi, in case we use next() to forward to other middleware (e.g. errorHandler function) , how could we mock and verify the next function to be called with correct parameter ?
@ansonthedev
@ansonthedev Год назад
When you call next() inside the middleware function, remember that "next" function is a parameter passed to the middleware. So you would pass in a mocked function, e.g: const mockedNext = jest.fn(); Then you would assert that mockedNext was called, e.g: expect(mockedNext).toHaveBeenCalled() or expect(mockedNext).toHaveBeenCalledWith(...);
@AdnanDev-su5no
@AdnanDev-su5no 6 месяцев назад
Hi there, how would you mock the User model in typescript ?
@ansonthedev
@ansonthedev 6 месяцев назад
It's the same exact way, only difference is you will have TypeScript complaining about fields missing. If your user model is simple, you can just fill out all the fields. If it is complex and has a lot relations which end up with an object full of aggregated data (fields that map to objects), then you can either manually mock those objects too, or just mock the fields you need for the mock User and cast the object to a User manually to avoid TypeScript errors.
@AdnanDev-su5no
@AdnanDev-su5no 5 месяцев назад
@@ansonthedev Thanks a lot Anson. Keep up the good work :). I've been following your NestJs playlist and it helped me clear the coding round of one of the interviews I appeared for.
@raphaelspitz3682
@raphaelspitz3682 11 месяцев назад
good video thnaks
@ericsiddiq7634
@ericsiddiq7634 Год назад
Thanks ❤
Далее
11 ming dollarlik uzum
00:43
Просмотров 1,4 млн
#慧慧很努力#家庭搞笑#生活#亲子#记录
00:11
Teeth gadget every dentist should have 😬
00:20
Просмотров 975 тыс.
Express v5 Is HERE
10:44
Просмотров 19 тыс.
Testing Express REST API With Jest & Supertest
55:46
Просмотров 122 тыс.
Jest. Unit Тестирование в JavaScript
1:27:05
ExpressJS - OAuth2 with Discord
30:53
Просмотров 9 тыс.
Mocking Asynchronous Functions with Jest
21:50
Просмотров 70 тыс.