S
SolidJSNathan

Testing difficulties in solid-start

I'm running into some perplexing errors with Vitest in my SSR-enabled Solid Start app. In the imports two files, I get Cannot set properties of undefined (setting 'modhash'). In one, it's caused by import { isBefore, parseISO } from "date-fns". In the other, by import { CentralStoreContext } from "../root".
In at least one of the test files, I've done my best to abstract the component being tested away from the routing, but I'm still getting this error. My root.tsx:
...

export const CentralStoreContext =
createContext<ReturnType<typeof useCentralStore>>()

export default function Root() {
const ctx = useCentralStore()
const location = useLocation()
return (
<Html lang="en">
<Head>
<Title>SolidStart - With TailwindCSS</Title>
<Meta charset="utf-8" />
<Meta name="viewport" content="width=device-width, initial-scale=1" />
</Head>
<Body>
<Suspense>
<SessionProvider>
<Sidebar />
<CentralStoreContext.Provider value={ctx}>
<Routes>
<FileRoutes />
</Routes>
</CentralStoreContext.Provider>
<Scripts />
</SessionProvider>
</Suspense>
</Body>
</Html>
)
}
...

export const CentralStoreContext =
createContext<ReturnType<typeof useCentralStore>>()

export default function Root() {
const ctx = useCentralStore()
const location = useLocation()
return (
<Html lang="en">
<Head>
<Title>SolidStart - With TailwindCSS</Title>
<Meta charset="utf-8" />
<Meta name="viewport" content="width=device-width, initial-scale=1" />
</Head>
<Body>
<Suspense>
<SessionProvider>
<Sidebar />
<CentralStoreContext.Provider value={ctx}>
<Routes>
<FileRoutes />
</Routes>
</CentralStoreContext.Provider>
<Scripts />
</SessionProvider>
</Suspense>
</Body>
</Html>
)
}
And my vitest.config.ts:
/// <reference types="vitest" />
/// <reference types="vite/client" />
// πŸ‘† do not forget to add the references above
import { defineConfig } from "vite"
import solid from "solid-start/vite"
export default defineConfig({
plugins: [solid()],
server: {
port: 3000,
},
build: {
target: "esnext",
},
test: {
environment: "jsdom",
globals: true,
transformMode: { web: [/\.[jt]sx?$/] },
},
resolve: { conditions: ["development", "browser"] },
})
/// <reference types="vitest" />
/// <reference types="vite/client" />
// πŸ‘† do not forget to add the references above
import { defineConfig } from "vite"
import solid from "solid-start/vite"
export default defineConfig({
plugins: [solid()],
server: {
port: 3000,
},
build: {
target: "esnext",
},
test: {
environment: "jsdom",
globals: true,
transformMode: { web: [/\.[jt]sx?$/] },
},
resolve: { conditions: ["development", "browser"] },
})
N
Nathanβ€’263d ago
Any guidance you can offer, @lexlohr ?
AL
Alex Lohrβ€’263d ago
Sorry, I need to test the newest solid start myself. I am terribly busy, so I cannot promise a fast answer.
N
Nathanβ€’263d ago
Understood. I'm happy for whatever help I can get.
AL
Alex Lohrβ€’263d ago
Have you tried to update all dependencies?
N
Nathanβ€’262d ago
Just tried that. It had no effect.
AL
Alex Lohrβ€’262d ago
I might have some time on Saturday or Sunday later in the evening for a pair debugging session.
N
Nathanβ€’260d ago
Just saw this now. I can't tonight, unfortunately. But I appreciate the offer.
AL
Alex Lohrβ€’260d ago
Maybe we can find another date. I have tried to recreate the issue, but could not get the same error.
N
Nathanβ€’260d ago
I'm occupied tonight and tomorrow evening, but my schedule is otherwise pretty open
AL
Alex Lohrβ€’260d ago
Maybe Tuesday 9pm CEST works for you?
N
Nathanβ€’260d ago
Yeah, that would work CEST = Central European Standard?
AL
Alex Lohrβ€’260d ago
central european summer time = UTC+2 might be a few minutes later, depending on when my kids fall asleep
N
Nathanβ€’260d ago
Got it. See you then.
AL
Alex Lohrβ€’258d ago
okay, I'm here
N
Nathanβ€’258d ago
cool How should we do this?
AL
Alex Lohrβ€’258d ago
Should I open a GotoMeeting so you can share your screen?
N
Nathanβ€’258d ago
Sure Do I need to install anything for that?
AL
Alex Lohrβ€’258d ago
Just a browser (preferably not firefox, because it's media capabilities are notoriously bad). https://app.goto.com/meeting/779414933 Thank you for your time.
N
Nathanβ€’258d ago
I just put all changes into a testing_problems branch and pushed it
Want results from more Discord servers?
Add your server
More Posts
ReactSVG like component in SolidHey, I recently was remaking my portfolio website in astro with some solid.js. I wanted to make an iSuspense not updating when navigating to Route directlyHey folks, I am currently having a weird issue I can't quite solve: We have a route which receivesHow do you do logging errors etc. In solid start?Like how do you get logs you can browse for instance in a web interface when solid start app is runnwarnings when passing onClick as propI get a warning in the child component when I pass an event handler from the parent. In the parenRoutes are being duplicated when HMR is onIt seems whenever the file updates the route is not actually refreshed and it just adds the updated Solidstart Astro or ViteCreated a SolidStart project and saw that it was using Astro. Looking at the docs it says the projecsibling componentsI've read the docs, and I just can't wrap my head around how to trigger a function in a sibling comptesting createRouteAction$ using vitestHi all! How do I go about testing createServerAction$ in vitest? I'm basically writing ``` export fucreateResource returns undefinedHello, goodnight everyone. Im having a problem using createResource. This function returns me undefiSuspense doesn't seem to work with ContextProviderhey, so recently I noticed, If I use `createResource(fetch)` and then put `<Suspense fallback={<PlLayout for layout groupTo make a layout for a route you need to make a .tsx file with the same name as the parent folder. BHow to deploy an solid js app myselfHi all, good morning. Does anyone have a resource (blog post, tutorial, vΓ­deo, etc) teaching how to SVG A elements not created correctlyWhen using an <a> element with <Show> or <For> inside an inline SVG element, we get the namespace wrHow to add events for scrolling like React? (with solid-qurey)Hi, I've only been dealing with React projects and I'm practicing Solid-js. `createResource` offerWhat's the best way to create multiple layouts that only some routes use?I need to have multiple layouts. I'd like some pages to use different layouts, rather than a single Looking for best way to re-validate route data after some arbitrary amount of time.Hi all, good morning/afternoon/night. So, i have a routed component with nested routes that share a How to stop VS Code from erroring with `Cannot find name 'React'.ts(2304)`?VS Code is complaining with `Cannot find name 'React'.ts(2304)` but I am not using React at all. I hHow should I use createRouteData``` export function routeData({ params, location }: RouteDataArgs) { return createServerData$( How can I access a store from the parent context from inside of a nested context?I am trying to access the WebsocketContext from inside of the DataStreamContext, in order to send ouUsing `createResource` without triggering suspenseI'm trying to use `createResource` without triggering Suspense. I realised that `data.latest` still