background icons
background icons 2

Video Belajar

Tonton dan pelajari berbagai topik menarik melalui video pembelajaran eksklusif dari Channel Dave Gray.

Dave Gray

20207

How to Mock a REST API Server for Testing with Jest & React Testing Library

Web Dev Roadmap for Beginners (Free!): https://bit.ly/DaveGrayWebDevRoadmap

Learn how to mock a Rest API Server for testing with Jest & React Testing Library. In this video, we will mock a REST API Server with MSW and write async unit and integration tests for a Next.js app.

💖 Support me on Patreon ➜ https://patreon.com/davegray

⭐ Become a full-stack web dev with Zero To Mastery Courses:
- Complete Next.js Developer: https://bit.ly/CompNextJSDev
- Advanced React: https://bit.ly/AdvReactDev
- Junior to Senior Dev Roadmap: https://bit.ly/WebDevRoadmap-JrtoSr

🚩 Subscribe ➜ https://bit.ly/3nGHmNn

📬 Course Updates ➜ https://courses.davegray.codes/

❓ Questions - Please post them to my Discord ➜ https://discord.gg/neKghyefqh

☕ Buy Me A Coffee ➜ https://www.buymeacoffee.com/davegray

👇 Follow Me On Social Media:
GitHub: https://github.com/gitdagray
Twitter: https://twitter.com/yesdavidgray
LinkedIn: https://www.linkedin.com/in/davidagray/

🔗 Starter Source Code: https://github.com/gitdagray/next-testing-example-app
🔗 Completed Source Code: https://github.com/gitdagray/nextjs-async-testing
📺 "Testing Your Code" playlist: https://www.youtube.com/playlist?list=PL0Zuz27SZ-6NTWVG8eM7Dt43vvzulnIbK

How to Mock a REST API Server for Testing with Jest & React Testing Library

(00:00) Intro
(00:14) Welcome
(00:38) Prerequisites & Starter Code
(01:00) Lesson Goal
(01:07) Adding Dependencies
(02:39) Mock REST API Server Setup
(08:57) Async Unit Testing
(13:38) Modify the Server Response for a test
(16:18) Completing the Mock Endpoint handlers
(19:02) Completing the CRUD Unit Tests
(23:18) Adding the Async CRUD functions to the app
(30:11) Adding New & Updating Integration Tests
(41:14) Unit Test Update
(43:27) Wrap-up

📚 Tutorial References:
🔗 Next.js Official Site: https://nextjs.org/
🔗 React Testing Library: https://testing-library.com/docs/react-testing-library/intro
🔗 Jest: https://jestjs.io/
🔗 TypeScript: https://www.typescriptlang.org/
🔗 MSW: https://mswjs.io/
🔗 MSW on npm: https://www.npmjs.com/package/msw

Was this tutorial about how to create a Mock REST API Server and async testing helpful? If so, please share. Let me know your thoughts in the comments.

#mock #rest #api