solid-testing-library icon indicating copy to clipboard operation
solid-testing-library copied to clipboard

Testing with Router involved (SPA code)

Open dominikzogg opened this issue 1 year ago • 3 comments

I was upgrading by solid demo repository and got the following

 FAIL  tests/app.test.tsx [ tests/app.test.tsx ]
Error: Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>.
 ❯ Module.notSup node_modules/.pnpm/[email protected]/node_modules/solid-js/web/dist/server.js:1136:9
    1134| }
    1135| function notSup() {
    1136|   throw new Error(
       |         ^
    1137|     "Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>."
    1138|   );
 ❯ node_modules/.pnpm/@[email protected][email protected]/node_modules/@solidjs/router/dist/index.js:1636:49
 ❯ tests/app.test.tsx:4:31

My current PR: https://github.com/chubbyts/solid-petstore/pull/3/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519

Code: https://github.com/chubbyts/solid-petstore/blob/vendor-upgrade/src/app.tsx Test: https://github.com/chubbyts/solid-petstore/blob/vendor-upgrade/tests/app.test.tsx

The code seems to run as before the upgrade (no issue) but any test i wrote related to router has this error message.

To be honest i have no clue if this it the right place to post this, nor if i fucked up in the first place.

dominikzogg avatar Jan 05 '25 18:01 dominikzogg

Thank you for the report, I'll have a look.

atk avatar Jan 05 '25 19:01 atk

go the same error after updating a few solidjs and vite testing packages

Error: Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>. ❯ notSup node_modules/solid-js/web/dist/server.js:1138:9 ❯ rtlRender node_modules/@solidjs/testing-library/dist/index.js:55:65 53| } 54| }) : wrappedUi; 55| const dispose = hydrate ? solidHydrate(routedUi, container) : solidRender(routedUi, container); | ^ 56| mountedContainers.add({ container, dispose }); 57| const queryHelpers = getQueriesForElement(container, queries);

nmocruz avatar Jan 27 '25 18:01 nmocruz

happens when updated to vitest 3.X, when when downgrade to 2.x

nmocruz avatar Jan 27 '25 19:01 nmocruz