New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: useActionData cannot be mocked #317
Comments
It sounds like you might need to inline the dependency to get this to work like that. (reference). Have you tried that? |
also running into this issue, any luck @cjoecker ? I also looked into rendering validated form in a remix stub (an experimental testing utility for remix seen used here https://github.com/remix-run/remix/blob/dev/packages/remix-testing/__tests__/stub-test.tsx) but that also didn't work unfortunately |
@madmax141 nope. Also still no answer in the |
Looks like we are seeing this newly in our E2E tests after updating to Remix v2 and remix-validated-forms 5.1.3 Seems to be fixed in 5.1.4 :) |
It seems this error is happening in actual apps too, not just in vitest. It's looking like it's a dependency resolution problem where RVF is pulling in a different version of remix from the rest of the app. |
This should be fixed now in 5.1.5. |
@airjp73 I updated all dependencies in the codesandbox but I still get the same error 😭 |
I got this answer from the |
As a workaround for the people still struggling with this, I'm using now the createRemixStub for mocking the |
Which packages are impacted?
remix-validated-form
@remix-validated-form/with-zod
@remix-validated-form/with-yup
zod-form-data
What version of these packages are you using?
remox-validated-form
: 5.0.2Please provide a link to a minimal reproduction of the issue.
https://codesandbox.io/p/sandbox/react-typescript-forked-vzq65s?file=%2Fsrc%2FApp.test.tsx%3A14%2C24
Steps to Reproduce the Bug or Issue
vitest
andtesting-library
ValidatedForm
to a component and render it in a testuseActionData
Expected behavior
useActionData
is moked and the erroruseActionData must be used within a data router
is not shownAdditional context
I know that
useActionData
is mocked because in themockImplementation
I'm logging something that is shown in the console of the test because I also use the hook in theDemo
component.But
ValidatedForm
is not using the mock and I still don't know why.The text was updated successfully, but these errors were encountered: