Mocking APIs During Development in React

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 ม.ค. 2025

ความคิดเห็น • 29

  • @leighhalliday
    @leighhalliday  3 ปีที่แล้ว

    Check out my course called Next Level Next.js! A full stack course covering GraphQL, TypeScript, Apollo, Prisma, auth and lots more! next.leighhalliday.com

    • @estebanvan4864
      @estebanvan4864 3 ปีที่แล้ว

      Pro trick : you can watch movies on Flixzone. Been using them for watching loads of movies during the lockdown.

    • @clayjohnathan6734
      @clayjohnathan6734 3 ปีที่แล้ว

      @Esteban Van definitely, I have been watching on Flixzone} for since december myself :D

  • @DevtoolsTech
    @DevtoolsTech 3 ปีที่แล้ว +7

    Mocking APIs is really important. Sometimes Back-end is not ready and you want to work in parallel. We can mock based API contracts and test end to end flow. Thanks for sharing! 🚀

  • @thearcticmonkey
    @thearcticmonkey 3 ปีที่แล้ว +2

    Thanks for this video.
    I actually looked into MSW recently to introduce tests in components that use React Query!

    • @vigneshs2886
      @vigneshs2886 3 ปีที่แล้ว

      you mean like integration tests? because I don't think unit test will require it.

    • @leighhalliday
      @leighhalliday  3 ปีที่แล้ว

      Thanks Arctic! Glad you enjoyed the vid! MSW is awesome!

  • @ridl27
    @ridl27 3 ปีที่แล้ว +1

    interesting topic, never thought about mocking api before. ty!

    • @leighhalliday
      @leighhalliday  3 ปีที่แล้ว +1

      No prob Alex! It's useful if a different team is working in parallel on a new API... this way you can get unblocked before the API is actually ready.

  • @rangabharath4253
    @rangabharath4253 3 ปีที่แล้ว

    Awesome as always 👍😀

    • @leighhalliday
      @leighhalliday  3 ปีที่แล้ว

      Thanks Ranga! I appreciate it!

  • @rimaaugustine6048
    @rimaaugustine6048 3 ปีที่แล้ว

    thank you, Leigh! it helps me a lot.

  • @bscodev
    @bscodev 3 ปีที่แล้ว

    Amazing thanks Leigh!

  • @TiberiusGracchi
    @TiberiusGracchi 3 ปีที่แล้ว

    Great content. Thanks!

  • @TrippleMYouAlreadyKnow
    @TrippleMYouAlreadyKnow 3 ปีที่แล้ว

    Very good video!

  • @76Freeman
    @76Freeman 3 ปีที่แล้ว

    Hey Leigh,
    Thank you very much for the great video, this can be really a life save :)
    By the way, do you know if this works for tests too?

    • @leighhalliday
      @leighhalliday  3 ปีที่แล้ว +1

      Thanks Helio! It does!! I have a video on it actually :) th-cam.com/video/v77fjkKQTH0/w-d-xo.html

    • @ivanderlich7501
      @ivanderlich7501 2 ปีที่แล้ว

      @@leighhalliday How much code can we recycle for testing?

  • @oiojin831
    @oiojin831 2 ปีที่แล้ว

    If you set this up in remix project, should I put importing "../mocks" inside of "root.jsx"?
    That causes me an issue that root.jsx will run on client side.
    Do you have better idea to solve this?
    Thanks

    • @oiojin831
      @oiojin831 2 ปีที่แล้ว

      I actually put "require("../mocks");" inside of "context.client.tsx".
      Does anyone know if this is ok?

    • @oiojin831
      @oiojin831 2 ปีที่แล้ว

      BTW, thanks for the great contents!

    • @oiojin831
      @oiojin831 2 ปีที่แล้ว

      I moved back to "root.tsx"
      and used NODE_ENV
      ```if (process.env.NODE_ENV === "development") {
      require("../mocks");
      }
      ```

    • @leighhalliday
      @leighhalliday  2 ปีที่แล้ว

      Hey Eung! Honestly I don't have a great answer for you... I haven't done any testing in Remix, and it doesn't seem like they have a testing guide on their website. I would recommend popping into the Remix Discord channel and asking what they recommend.

  • @Leonardo-bx6kh
    @Leonardo-bx6kh 3 ปีที่แล้ว

    25 minutes to nothing! To make a Json-server is 30 seconds, but how can I call it from my app ?