ExpressJS - Jest & Unit Testing

  Рет қаралды 26,956

Anson the Developer

Anson the Developer

Күн бұрын

Пікірлер: 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.
@UdayKiranK-t9q
@UdayKiranK-t9q 3 ай бұрын
thank you for this tutorial, helped me understand the fundamentals of unit testing
@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!
@StalkingPlagiarist
@StalkingPlagiarist 2 жыл бұрын
Another awesome video, best explanation on testing I found so far on YT 🤘🤘🤘
@rady6546
@rady6546 Жыл бұрын
This is integration testing not unit because unit testing haven't side effect
@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 { ... } }
@marshelaillon
@marshelaillon Жыл бұрын
What vsc theme are you using?
@ericsiddiq7634
@ericsiddiq7634 Жыл бұрын
Thanks ❤
@pandagamedev1177
@pandagamedev1177 3 ай бұрын
what theme of vs did you use in this video
@AdnanDev-su5no
@AdnanDev-su5no 7 ай бұрын
Hi there, how would you mock the User model in typescript ?
@ansonthedev
@ansonthedev 7 ай бұрын
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 6 ай бұрын
@@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.
@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(...);
@raphaelspitz3682
@raphaelspitz3682 Жыл бұрын
good video thnaks
Unit Testing with JEST in 80 Minutes - CRASH COURSE (NODE JS)
1:17:33
小丑家的感情危机!#小丑#天使#家庭
00:15
家庭搞笑日记
Рет қаралды 38 МЛН
Бенчик, пора купаться! 🛁 #бенчик #арти #симбочка
00:34
Симбочка Пимпочка
Рет қаралды 3,9 МЛН
ExpressJS - More Unit Testing Examples with Jest
29:57
Anson the Developer
Рет қаралды 2,7 М.
Testing Express REST API With Jest & Supertest
55:46
TomDoesTech
Рет қаралды 123 М.
Introduction to Jest Testing | JavaScript Unit Tests
25:30
Dave Gray
Рет қаралды 32 М.
🤯 Express.js 5 is here (since a month already, actually)
9:58
Mocking a Database in Node with Jest
13:29
Sam Meech-Ward
Рет қаралды 68 М.
ExpressJS - OAuth2 with Discord
30:53
Anson the Developer
Рет қаралды 9 М.
Jest. Unit Тестирование в JavaScript
1:27:05
Владилен Минин
Рет қаралды 170 М.
Why aren't you using Fastify? Or Koa? Or NestJS?
9:58
Maximilian Schwarzmüller
Рет қаралды 59 М.