menu

Testing Library

Simple and complete DOM testing utilities that encourage good testing practices.

Channels
Chat
view-forward
# All channels
view-forward
# General
view-forward
# General Help
view-forward
# Angular Help
view-forward
# Cypress Help
view-forward
# DOM Help
view-forward
# React Help
view-forward
# TestCafe Help
view-forward
# Vue Help
view-forward
Team

Using Mirage with Testing Library to mock the network

January 31, 2020 at 3:36pm

Using Mirage with Testing Library to mock the network

January 31, 2020 at 3:36pm (Edited 2 months ago)
Hey Testing Library community!
I've been using TL more and more recently and really love it. I've worked a lot with Ember's testing in the past and philosophically, TL is very aligned with that. The goal is to always keep tests written at one level of abstraction, and the highest-level UI tests should be written from the perspective of the end user.
Mirage is an API mocking library I maintain that recently became framework-agnostic. It pairs perfectly with TL as it keeps implementation details about the network outside of your test suite, and prevents your tests from becoming brittle.
Anyway, I wanted to share Mirage here, in case anyone finds it helpful, and also to hear what other approaches folks are taking to mock out the network when writing UI tests.
Here's a video of me writing some tests with React/Jest/Mirage/Testing Library:
And here's the project's website: https://miragejs.com
Look forward to hearing what you think, and happy testing!

January 31, 2020 at 3:40pm
Awesome! I've been thinking about using Mirage JS with react testing library lately, so this example is quite useful for me. Thanks for sharing!
like-fill
1
  • reply
  • like