#Test with useRouteData fail
29 messages · Page 1 of 1 (latest)
Sorry, I'm currently a bit short on time. Our router can either use the location and history API as source of the state and params, or the URL hash or just keep a mock of those in memory (mostly used for testing). You just need to import { memoryIntegration } from "@solidjs/router"; and use its return value inside the source attribute of the router you use for testing. Obviously, that means that it is difficult to use the actual Root, since that includes the router. I suggest you test a level higher and wrap the components your router is pointing to into an in-memory router.
If you use the newest version of @solid/testing-library, you can use the new options.location to automatically set up a test router and point it at a certain route. There's no option to set the route data yet, though. If you give me a little more time, maybe I can add it for your convenience.
The way you use <Component /> is slightly problematic. <Dynamic /> should solve this issue, but this should only have any impact if you are testing reactive changes.
In any case, this addition was pretty simple to implement. I'll have to test it more thorougly and release it in the evening.
So you can soon just use render(() => <Home>, { routeDataFunc: () => mockRouteData });
It's published, so I hope testing becomes even more convenient for you.
Ah, forgot an await.
FindByText returns a promise.
I need to fix the docs tomorrow.
Too late for me now.
What are your pain points? (I intend to solve all of them)
I just hotfixed the documentation, but it will need the next release to reflect that on npmjs.
The text being broken up into several text nodes should not make any difference. Testing-libary's queries can concatenate text nodes and ignore comments that are in between. A very similar example is in my unit tests for the testing library: https://github.com/solidjs/solid-testing-library/blob/main/src/__tests__/routes.tsx#L21
I think you need to prefix the location with "/".
The memory integration does not normalize the path.
Unfortunately, yes.
I have just researched this and will soon release improved error messaging and documentation.
I'll have a look later.
Which version of solid-start?
Maybe I need to fix its vite plugin.
Thanks for the info. I'll look into it later.
We might need to put /solid-start/ into the inlined deps, too.
The source of the modules does not indicate whether they are loaded via node or the vite server.
I have to assume the islands architecture is not really working with SSR mode.
I need to debug deeper.
Unfortunately, my time is too limited to yield faster results.
I think parts of the islands stuff leaked into the router adapter.