Testing Node Server with Jest and Supertest

  Рет қаралды 114,494

Sam Meech-Ward

Sam Meech-Ward

3 жыл бұрын

Learn how to test a node.js HTTP server using Jest and Supertest.
🔗 Previous Videos:
Introduction to Writing Automated Tests With Jest: • Unit Testing in Javasc...
Introduction to TDD in JavaScript: • TDD in JavaScript | Te...
🔗 Text version:
sammeechward.com/testing-an-e...
🔗 Using Jest with ESModules:
sammeechward.com/jest-and-esm...
🔗 Code:
github.com/Sam-Meech-Ward/exp...
🔗 Moar Links
My Website: www.sammeechward.com
Instagram: / meech_ward
Github: github.com/orgs/Sam-Meech-Ward
TikTok: / meech.s.ward

Пікірлер: 82
@ovienaduken7296
@ovienaduken7296 3 жыл бұрын
this is a very straight forward way to explain testing with supertest. Thanks
@VladBurlutsky
@VladBurlutsky 2 жыл бұрын
Just did a random search and came across this video. Very good, Sam!Keep up the good work!
@JJP-lb3ek
@JJP-lb3ek 3 жыл бұрын
Exactly what i needed in my life right now. Thanks!
@jesuscama5354
@jesuscama5354 2 жыл бұрын
Thanks for keeping it simple and clean. 🚀
@wralith
@wralith 2 жыл бұрын
It was just what I was looking for. Thank you very much for the clear explanation.
@shahilhussain6466
@shahilhussain6466 Жыл бұрын
That was very quick and simple explanation and use case of Jest and SuperTest, thanks man!.
@BlackDragon-rj4sc
@BlackDragon-rj4sc 6 ай бұрын
I just started to create my first nodejs boilerplate with jest test and this video was very helpful to setup things
@leetcodeking4859
@leetcodeking4859 Жыл бұрын
Hi. I just move to California from China, this is the best video I seen on topic. Thank you friend.
@suhasvenkatesh7895
@suhasvenkatesh7895 3 жыл бұрын
Awesome, simple to understand. Simplicity in explanation. Thanks
@Shailendrakumar-ge5cf
@Shailendrakumar-ge5cf Жыл бұрын
Thank you so much for the text version ♥
@utsavojha2953
@utsavojha2953 3 жыл бұрын
Great video, great explanation !! Thanks 🤩
@leandrodavimg
@leandrodavimg 2 жыл бұрын
Great video, simple and explained very well about supertest
@debanjanbarman7212
@debanjanbarman7212 3 жыл бұрын
Thanks, bro. It helped me. Keep up the good work.
@babykosh5415
@babykosh5415 Жыл бұрын
THANK YOU for doing the pseudo code steps!
@realmonzeromer
@realmonzeromer 2 жыл бұрын
I was struggling with this Thank you so much for your hard work I subscribed
@Sergio-ef5pz
@Sergio-ef5pz 2 жыл бұрын
Great content mate! I'm on my first month as a backend dev with Node/Express and I'm looking forward to getting to know testing tools. Thanks for your explanation!
@giachan4528
@giachan4528 2 жыл бұрын
I like these testing tutorials with examples. Thanks
@SamMeechWard
@SamMeechWard 2 жыл бұрын
You are welcome 🤗
@kostiantynkarzhanov9216
@kostiantynkarzhanov9216 7 ай бұрын
Very good tutorial! Thank you! 💛
@karinaillesova5706
@karinaillesova5706 2 жыл бұрын
Hi, this was great video to watch while creating my first tests for my API endpoints. It does however make changes to my actual database. Would you make a video on mongodb-memory-server please?
@djvanschaik
@djvanschaik 2 жыл бұрын
If you get a request not defined error, make sure to try: `const request = require('supertest')` instead of `const supertest = require('supertest')`. Other than that this is great!
@sheheerali7059
@sheheerali7059 Жыл бұрын
i should have looked at this comment earlier😅
@nested9301
@nested9301 7 ай бұрын
"type":"module"
@user-rq6ti7cy2q
@user-rq6ti7cy2q 6 ай бұрын
after done this I get ReferenceError: require is not defined ca you help me with this?
@debashisroyroy652
@debashisroyroy652 3 жыл бұрын
helpFull .. Thank You. Expecting more nice things from you.
@scrice9081
@scrice9081 Жыл бұрын
thanks man this is awesome!!!
@guillaume5623
@guillaume5623 10 ай бұрын
Great content, thank you
@JigneshPatel-jr5bj
@JigneshPatel-jr5bj 2 жыл бұрын
Great, thanks for this video!
@SamMeechWard
@SamMeechWard 2 жыл бұрын
Glad you enjoyed it!
@he01682936
@he01682936 3 жыл бұрын
Nice video, thanks :)
@alex-dk2rj
@alex-dk2rj 2 жыл бұрын
Great stuff!
@tech3425
@tech3425 Жыл бұрын
Thanks a lot for this! Would appreciate it if you could make a video regarding setup for this kind of test suite with Typescript-Express
@ayushpratap4726
@ayushpratap4726 3 жыл бұрын
waiting for the next part ! Try using Nest.JS with JEST Supertest.
@brentryczak
@brentryczak Жыл бұрын
Instant like after that first tip about the ports. That was my issue
@attilaszombathelyi3
@attilaszombathelyi3 4 ай бұрын
great job
@tom_c
@tom_c Жыл бұрын
Sam, great video! Thank you for contributing to the community... I am having a problem trying to reproduce the core of what you explained. For some reason the test fails saying that the request received a 404 but it should be a 403 (returned correctly testing it via postman). I think it has something to do with the routes and passing the app object to the request function of supertest... Any comments would be appreciated. Thank you in advance!
@ngneerin
@ngneerin 2 жыл бұрын
Have been trying to fix supertest with async app. Got fixed after watching this video
@jbkwon
@jbkwon Жыл бұрын
You are so awesome!
@antimaaaato
@antimaaaato 3 жыл бұрын
Nice video! Could you tell me your Node.js and jest, supertest versions?
@harmanmax
@harmanmax 2 жыл бұрын
Thanks mate , in windows i am using cross-env package and in package.json "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --watchAll"
@zainhaider1633
@zainhaider1633 2 жыл бұрын
hey great video but i wan to know how not to affect you actual DB during test?
@sammygopeh7578
@sammygopeh7578 Жыл бұрын
Lord! I cannot say thank you and enough
@SamMeechWard
@SamMeechWard Жыл бұрын
consider becoming a channel member ;)
@MattBodman
@MattBodman 2 жыл бұрын
Love the vids! What's the music in this one?
@Codethier
@Codethier 3 жыл бұрын
i owe you a beer mate
@danielsouza1824
@danielsouza1824 2 жыл бұрын
Thank you very much, the NODE_OPTIONS=--experimental-vm-modules npx jest solved my problem 😓
@Mercio2
@Mercio2 2 жыл бұрын
thanks
@saulramirez727
@saulramirez727 2 жыл бұрын
Supervideo of superset
@nwigweuzochukwu6089
@nwigweuzochukwu6089 3 жыл бұрын
In a user registration flow that involves sending verification emails, i'm getting this type of error: thrown: "Exceeded timeout of 5000 ms for a test. I guess it's because of the email sender request and response but how do i fix this?
@12kenbutsuri
@12kenbutsuri 3 жыл бұрын
Thank you for the tutorial. I'm a bit confused with one thing though, when was supertest ever used? wasn't everything here contained in jest?
@krsnyder128
@krsnyder128 3 жыл бұрын
At 4:36 he mentions that the request function comes from supertest!
@12kenbutsuri
@12kenbutsuri 3 жыл бұрын
@@krsnyder128 thank you! I missed that part.
@trant4
@trant4 2 жыл бұрын
@@krsnyder128 Does not work for me, request is underfined
@prerakhere
@prerakhere 9 күн бұрын
is supertest used for unit or integration testing? i read at a lot of places on the internet that it is used for integration testing. i am confused.
@RajendraPrasadyk
@RajendraPrasadyk Жыл бұрын
Can we get video on with middleware supertest
@TheSerikzhan
@TheSerikzhan 2 жыл бұрын
nice
@daniel.w8112
@daniel.w8112 3 ай бұрын
where do we use jest here ?
@danielsouza1824
@danielsouza1824 2 жыл бұрын
How to overcome "Jest did not exit one second after the test run has completed."? Now I'm facing this problem. Did you solve that?
@cannabisanomaly
@cannabisanomaly 9 ай бұрын
Anyone been able to figure out how to use EJS syntax for importing/exporting on the backend instead of CJS? I still haven't been able to figure out how to configure that 😅
@FredWang
@FredWang Жыл бұрын
To use `import express from 'express'`, are you using the latest node version or by importing ESM ?
@user-lb8to5yr6r
@user-lb8to5yr6r Жыл бұрын
He wrote "type": "module" at the package.json file. It tells node.js to use ECMAScript modules instead of a default CommonJS
@22SPORTSLIVE_10
@22SPORTSLIVE_10 Жыл бұрын
Can someone help with some unit test plz
@aprilm2941
@aprilm2941 3 жыл бұрын
🤗
@SamMeechWard
@SamMeechWard Жыл бұрын
🤗
@runyalen
@runyalen Жыл бұрын
Hi whe i use "describe" error lens extention sais "describe is not defined" :/
@SamMeechWard
@SamMeechWard Жыл бұрын
Error lense is a jerk
@ezeanichucks3728
@ezeanichucks3728 Ай бұрын
Dude, I hope I can repay you someday🎉
@JBeique
@JBeique 2 жыл бұрын
TDD sure is SUPER with SUPER TESTS
@clasesutnfrc8699
@clasesutnfrc8699 2 жыл бұрын
04:20 Request with supertest
@eddyeffy
@eddyeffy 10 ай бұрын
Something is wrong with your dependecies
@ms.Mysh1
@ms.Mysh1 Жыл бұрын
I can’t concentrate because of your beautiful face 😅
@TenthFir
@TenthFir 9 ай бұрын
Why do you guys add music to a course video... I am here to learn. And even the music volume is more than your speech
@SamMeechWard
@SamMeechWard 9 ай бұрын
No guys, just me. I like the music 🤗
@arcan762
@arcan762 2 жыл бұрын
bruh turn the music down it is so annoying the way it jumps all over the place
@sohrabradmehrgaming1556
@sohrabradmehrgaming1556 2 жыл бұрын
You should become a teacher or something
@SamMeechWard
@SamMeechWard 2 жыл бұрын
I don't think i'd be able to put up with the students
@matthewbeardsley7004
@matthewbeardsley7004 2 жыл бұрын
Having this as my script saved me hours!! Thanks!! "test": "NODE_OPTIONS=--experimental-vm-modules jest"
@alidemircix
@alidemircix 2 жыл бұрын
Why does not work only writing npm test for this. I spent about 2 hours to solve this problem but I don't know why do we use "test": "NODE_OPTIONS=--experimental-vm-modules jest" code
@djaos-8326
@djaos-8326 Жыл бұрын
thanks
@SamMeechWard
@SamMeechWard Жыл бұрын
You're welcome!
Dependency Injection in JavaScript
9:37
Sam Meech-Ward
Рет қаралды 40 М.
When To Unit, E2E, And Integration Test
14:58
ThePrimeTime
Рет қаралды 92 М.
БАБУШКИН КОМПОТ В СОЛО
00:23
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 18 МЛН
Summer shower by Secret Vlog
00:17
Secret Vlog
Рет қаралды 13 МЛН
A little girl was shy at her first ballet lesson #shorts
00:35
Fabiosa Animated
Рет қаралды 15 МЛН
Mocking a Database in Node with Jest
13:29
Sam Meech-Ward
Рет қаралды 65 М.
Testing Express REST API With Jest & Supertest
55:46
TomDoesTech
Рет қаралды 117 М.
Test-Driven Development // Fun TDD Introduction with JavaScript
12:55
tRPC, gRPC, GraphQL or REST: when to use what?
10:46
Software Developer Diaries
Рет қаралды 76 М.
NodeJS Express Test-Driven API Development (TDD)
32:21
Marius Espejo
Рет қаралды 57 М.
Stop Writing So Many Tests
10:02
Web Dev Simplified
Рет қаралды 85 М.
Every Developer Needs a Raspberry Pi
27:27
Sam Meech-Ward
Рет қаралды 11 М.
The ONLY REASON To Unit Test
8:26
Theo - t3․gg
Рет қаралды 75 М.
Kumanda İle Bilgisayarı Yönetmek #shorts
0:29
Osman Kabadayı
Рет қаралды 2,4 МЛН
Проверил, как вам?
0:58
Коннор
Рет қаралды 257 М.
НОВЫЕ ФЕЙК iPHONE 🤯 #iphone
0:37
ALSER kz
Рет қаралды 357 М.