easier mocking of external APIs with remix #4980
cellog
started this conversation in
Show and tell / tips
Replies: 2 comments
-
Thanks for sharing - always great to learn how people are testing their remix apps ✨
(1) can you explain a little bit more about how sqlite3 facilitates the communication between cypress & msw? |
Beta Was this translation helpful? Give feedback.
0 replies
-
The problem is that Cypress has no visibility inside the apps it is testing
on the server-side. So if your app makes a request to an external API on
the server (which is recommended practice for remix and nextjs), you can
intercept it with MSW, but what if you want to test 3 different responses?
This allows changing the response mid-test run.
…On Sat, Dec 31, 2022, 14:58 Clifford Fajardo ***@***.***> wrote:
Thanks for sharing - always great to learn how people are testing their
remix apps ✨
a sqlite database is used as a means of communicating between Cypress and
the msw instance inside your remix app.
...
This package uses an sqlite database to control which of a list of
alternative mock handlers should be used. - msw-server-helper repo
<https://github.com/cellog/msw-server-helper/blob/160f22401f193a079b7abfd80c8c3fb48efad33a/packages/msw-server-helper-cypress/README.md?plain=1#L5>
can you explain a little bit more about how sqlite3 facilitates the
communication between cypress & msw?
Or rephrased, without sqlite3 what challenges were you facing, what
couldn't be done before?
—
Reply to this email directly, view it on GitHub
<#4980 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAX7SQ22JUDY2QBKNZRWFTWQCF77ANCNFSM6AAAAAATNJD7YY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, I've just released https://github.com/cellog/msw-server-helper#readme as a solution to controlling
msw
mocks from cypress tests.It's pretty simple: an sqlite database is used as a means of communicating between Cypress and the msw instance inside your remix app. This allows using
cy.enableMockOverride()
inside cypress tests to control which mock to return from an internal API call.This solves the problem I ran into of "how do I control a mock inside of a remix app?"
Specific examples of use cases I wanted to test but couldn't until now:
Beta Was this translation helpful? Give feedback.
All reactions