Open
Description
Which component is affected?
Qwik Runtime
Describe the bug
When attempting to vitest a component that invokes a routeAction$
I'm getting the error:
Error: Actions can not be invoked within the server during SSR.
Action.run() can only be called on the browser, for example when a user clicks a button, or submits a form.
at Proxy.routeActionQrl_action_submit_A5bZC7WO00A
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.
test('Should successfully remove users', async () => {
const Wrapper = component$(() => {
const removeDialogRef = useSignal<HTMLElement>();
const onClose$ = $(onCloseSpy);
return (
<QwikCityMockProvider>
<RemoveUsers
ref={removeDialogRef}
selectedUsers={selectedUsers}
close={onClose$}
/>
</QwikCityMockProvider>
);
});
const { render, userEvent } = await createDOM();
await render(<Wrapper />);
await userEvent('.vi-submit-remove', 'click');
});
Where within the RemoveUsers component it calls action.submit(data as unknown as FormData)
which ultimately makes an HTTP POST call.
Reproduction
Steps to reproduce
No response
System Info
System:
OS: macOS 14.3.1
CPU: (20) arm64 Apple M1 Ultra
Memory: 212.80 MB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
bun: 1.0.7 - /opt/homebrew/bin/bun
Browsers:
Chrome: 113.0.5672.126
Safari: 17.3.1
npmPackages:
@builder.io/qwik: ^1.4.3 => 1.4.3
@builder.io/qwik-auth: 0.1.3 => 0.1.3
@builder.io/qwik-city: ^1.4.3 => 1.4.3
@builder.io/qwik-react: 0.5.0 => 0.5.0
undici: 5.28.2 => 5.28.2
vite: 5.0.12 => 5.0.12
Additional Information
No response