Open engineersamwell opened 8 months ago
Hmm, so the QwikCityMockProvider should somehow make it so that actions run locally? Or should they be mocked entirely?
Sounds feasible but needs a good think about the API. PRs very welcome.
That's correct, in this context I'd want to mock the fetch calls for testing, however that doesn't mean there isn't a scenario in which one would want the action to run as normal as well.
@wmertens Help me understand the QwikCityMockProvider. If I look at https://github.com/QwikDev/qwik/blob/main/packages/qwik-city/runtime/src/qwik-city-component.tsx#L130 and https://github.com/QwikDev/qwik/blob/main/packages/qwik-city/runtime/src/qwik-city-component.tsx#L578 the actionState
is added as a context so theoretically actions should be able to be called. If I look at the error itself it happens here: https://github.com/QwikDev/qwik/blob/main/packages/qwik-city/runtime/src/server-functions.ts#L90 and I assume the error is thrown because HTMLFormElement
is not available from a SSR based action call.
Can you provide more thoughts on how this would be implemented? I'm happy to do some work here but I need to understand what exactly is missing and what needs to be either mocked out or filled it, in isn't exactly clear.
The huge windfall here would be the ability to rapidly test one's app with mocked data. The speed we could test if this was in place would be an order of magnitude faster vs cypress or playwright or any of the e2e testing libraries.
Which component is affected?
Qwik Runtime
Describe the bug
When attempting to vitest a component that invokes a
routeAction$
I'm getting the error:I thought that vitest would render using the node environment and thus SSR and I could mock out the HTTP API call that my action is ultimately making. This is not the case though and I can't find any good documentation on how to do this.
Where within the RemoveUsers component it calls
action.submit(data as unknown as FormData)
which ultimately makes an HTTP POST call.Reproduction
http://no.repro.url
Steps to reproduce
No response
System Info
Additional Information
No response