๐บ๏ธ Testing Helpers #4541
Replies: 0 comments 6 replies
-
This looks great to me! Just to clarify, this is intended for unit/integration tests for components that call Remix hooks/components, yeah? I assume you wouldn't use this to test your actual route components. |
Beta Was this translation helpful? Give feedback.
-
Instead of duck punching So inside of Remix components, instead of calling functions like |
Beta Was this translation helpful? Give feedback.
-
Prior Art:
Summary
This is a proposal for some new helpers for remix so that you can unit test a Remix Route without needing to manually mock everything under the sun. Note these helpers wouldn't be for testing a entire route module (importing your actual loader/action) as you would more than likely be hitting an actual database in that case and would be better off using a full integration test.
Background
It's currently next to impossible to test a Remix app without either manually mocking everything or extracting pieces out of components that don't use Remix hooks and pass everything in as props due to the hooks needing to read the manifest.
Proposal
Create a
createRemixStub
function which usage would look like:Implementation
The implementation for the above example would look like the following
A non tested, but theoretical "duck punch" of fetch could look like:
Open Questions
The big one is "how do we generate a Remix manifest and context from a RR route config?"
Beta Was this translation helpful? Give feedback.
All reactions