Web Dev Roadmap for Beginners (Free!): 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 ➜ / davegray
⭐ Become a full-stack web dev with Zero To Mastery Courses:
- Complete Next.js Developer: bit.ly/CompNextJSDev
- Advanced React: bit.ly/AdvReactDev
- Junior to Senior Dev Roadmap: bit.ly/WebDevRoadmap-JrtoSr
🚩 Subscribe ➜ bit.ly/3nGHmNn
📬 Course Updates ➜ courses.davegray.codes/
❓ Questions - Please post them to my Discord ➜ / discord
☕ Buy Me A Coffee ➜ www.buymeacoffee.com/davegray
👇 Follow Me On Social Media:
GitHub: github.com/gitdagray
Twitter: / yesdavidgray
LinkedIn: / davidagray
🔗 Starter Source Code: github.com/gitdagray/next-tes...
🔗 Completed Source Code: github.com/gitdagray/nextjs-a...
📺 "Testing Your Code" playlist: • Testing Your Code
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: nextjs.org/
🔗 React Testing Library: testing-library.com/docs/reac...
🔗 Jest: jestjs.io/
🔗 TypeScript: www.typescriptlang.org/
🔗 MSW: mswjs.io/
🔗 MSW on npm: 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
20 июл 2024